- if (fromScratch)
- MEDCoupling::WriteField(fname.c_str(),_field,fromScratch);
- else
- MEDCoupling::WriteFieldUsingAlreadyWrittenMesh(fname.c_str(),_field);
+
+ if(_mesh.isStructured() || _mesh.meshNotDeleted())
+ if (fromScratch)
+ MEDCoupling::WriteField(fname.c_str(),_field,fromScratch);
+ else
+ MEDCoupling::WriteFieldUsingAlreadyWrittenMesh(fname.c_str(),_field);
+ else//The mesh has ben deleted, use _ff instead of _field to save the values
+ {
+ //MEDFileUMesh * meshMEDFile = MEDFileUMesh::New();
+ //meshMEDFile->setMeshAtLevel(0,_field->getMesh()->buildUnstructured());
+ //meshMEDFile->write(fname.c_str(), fromScratch);
+ //MEDCoupling::WriteUMesh(fname.c_str(),_field->getMesh()->buildUnstructured(),fromScratch);
+ //MEDCoupling::WriteMesh(fname.c_str(),_field->getMesh(),fromScratch);
+ //MEDCoupling::MEDCouplingUMesh* fmesh = dynamic_cast<MEDCoupling::MEDCouplingUMesh*> (_field->getMesh()->deepCopy());
+ //cout<<" checkConsecutiveCellTypes : "<< fmesh->checkConsecutiveCellTypes() <<endl;
+ //cout<<" advancedRepr() : "<< fmesh->advancedRepr() <<endl;
+ //cout<<" checkConsecutiveCellTypes : "<< _field->getMesh()->buildUnstructured()->checkConsecutiveCellTypes()<<endl;
+ MEDFileField1TS *ff=MEDFileField1TS::New();
+ _ff->setFieldNoProfileSBT( _field );
+ _ff->write(fname.c_str(), fromScratch);
+ }