+ {
+ MCAuto<MEDFileFloatField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileFloatField1TS>(f));
+ if(f1.isNotNull())
+ {
+ MCAuto<MEDCoupling::MEDCouplingFieldFloat> ret(ReadFieldCellLikeT<float>(f1,type,fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
+ return ret.retn();
+ }
+ }
+ throw INTERP_KERNEL::Exception("MEDCoupling::ReadFieldCell : only FLOAT32, FLOAT64 and INT32 supported for the moment !");
+ }
+
+ template<class T>
+ MCAuto<typename Traits<T>::FieldType> ReadFieldNodeT(typename MLFieldTraits<T>::F1TSType *ff, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
+ {
+ MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
+ MCAuto<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
+ MCAuto<typename Traits<T>::FieldType> ret(ff->getFieldOnMeshAtLevel(ON_NODES,m));
+ MCAuto<MEDFileUMesh> muPtr(MEDCoupling::DynamicCast<MEDFileMesh,MEDFileUMesh>(mm));
+ if(ff->getPflsReallyUsed().empty())
+ {
+ if(muPtr.isNotNull())
+ {
+ const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax));
+ if(num)
+ ret->renumberCells(num->begin());
+ }
+ }
+ else
+ {
+ DataArrayInt *pfl(nullptr),*arr2(nullptr);
+ MCAuto<typename Traits<T>::ArrayType> arr(ff->getFieldWithProfile(ON_NODES,meshDimRelToMax,mm,pfl));
+ MCAuto<DataArrayInt> pflSafe(pfl);
+ MCAuto<DataArrayInt> mp(m->getCellIdsFullyIncludedInNodeIds(pfl->begin(),pfl->end()));
+ MCAuto<MEDCouplingUMesh> mzip(static_cast<MEDCouplingUMesh *>(m->buildPartAndReduceNodes(mp->begin(),mp->end(),arr2)));
+ MCAuto<DataArrayInt> arr2Safe(arr2);
+ MCAuto<DataArrayInt> arr3(arr2->invertArrayO2N2N2O(mzip->getNumberOfNodes()));
+ MCAuto<DataArrayInt> pflSorted(pflSafe->deepCopy()); pflSorted->sort(true);
+ if(!arr3->isEqualWithoutConsideringStr(*pflSorted))
+ throw INTERP_KERNEL::Exception("ReadFieldNode : not implemented yet !");
+ if(!arr3->isEqualWithoutConsideringStr(*pflSafe))
+ {
+ MCAuto<DataArrayInt> o2n2(pflSafe->checkAndPreparePermutation());
+ MCAuto<DataArrayInt> n2o2(o2n2->invertArrayO2N2N2O(o2n2->getNumberOfTuples()));
+ mzip->renumberNodes(n2o2->begin(),n2o2->getNumberOfTuples());
+ arr->setName("");
+ ret->setArray(arr);
+ }
+ ret->setMesh(mzip);
+ }
+ return ret;
+ }