]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
MEDFileField Gauss NE. Start_BR_19998_21191_NEW_ENV
authorageay <ageay>
Tue, 19 Apr 2011 08:39:14 +0000 (08:39 +0000)
committerageay <ageay>
Tue, 19 Apr 2011 08:39:14 +0000 (08:39 +0000)
src/MEDLoader/MEDFileField.cxx
src/MEDLoader/MEDFileField.hxx
src/MEDLoader/Swig/MEDLoaderTest3.py

index 69d20fe6ccc80ab1723926424501fb5e191af48a..4f6381359a3cf874b4df2a87d68045c7c57e12b0 100644 (file)
@@ -79,11 +79,13 @@ try:_father(fath),_profile_it(profileIt)
   TypeOfField type=getType();
   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
   int profilesize,nbi;
-  _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,type==ON_CELLS?MED_CELL:MED_NODE,type==ON_CELLS?typmai3[(int)geoType]:MED_NONE,profileIt,MED_COMPACT_PFLMODE,
+  med_geometry_type mgeoti;
+  med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
+  _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,profileIt,MED_COMPACT_PFLMODE,
                                   pflname,&profilesize,locname,&nbi);
   _arr=DataArrayDouble::New();
   _arr->alloc(_nval*nbi,infos.size());
-  MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,type==ON_CELLS?MED_CELL:MED_NODE,type==ON_CELLS?typmai3[(int)geoType]:MED_NONE,MED_COMPACT_PFLMODE,
+  MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
                              pflname,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(_arr->getPointer()));
   _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
   _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
@@ -162,7 +164,9 @@ void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid) const throw(INTERP_
 {
   TypeOfField type=getType();
   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
-  MEDfieldValueWithProfileWr(fid,getName().c_str(),getIteration(),getOrder(),getTime(),type==ON_CELLS?MED_CELL:MED_NODE,type==ON_CELLS?typmai3[(int)geoType]:MED_NONE,
+  med_geometry_type mgeoti;
+  med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
+  MEDfieldValueWithProfileWr(fid,getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
                              MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
                              reinterpret_cast<const unsigned char*>(_arr->getConstPointer()));
 }
@@ -241,7 +245,7 @@ std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
     {
       std::string tmp=(*it1)->getLocalization();
-      if(!tmp.empty())
+      if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
         ret.push_back(tmp);
     }
   return ret;
@@ -278,8 +282,9 @@ void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid) throw(INTERP_KERNEL:
   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
-  int nbProfiles=MEDfieldnProfile(fid,getName().c_str(),getIteration(),getOrder(),getType()==ON_CELLS?MED_CELL:MED_NODE,getType()==ON_CELLS?typmai3[(int)geoType]:MED_NONE,
-                                  pflName,locName);
+  med_geometry_type mgeoti;
+  med_entity_type menti=ConvertIntoMEDFileType(getType(),geoType,mgeoti);
+  int nbProfiles=MEDfieldnProfile(fid,getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
   _field_pm_pt_pd.resize(nbProfiles);
   for(int i=0;i<nbProfiles;i++)
     {
@@ -292,6 +297,25 @@ void MEDFileFieldPerMeshPerType::writeLL(med_idt fid) const throw(INTERP_KERNEL:
   _field_pm_pt_pd[0]->writeLL(fid);
 }
 
+med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
+{
+  switch(ikType)
+    {
+    case ON_CELLS:
+      medfGeoType=typmai3[(int)ikGeoType];
+      return MED_CELL;
+    case ON_NODES:
+      medfGeoType=MED_NONE;
+      return MED_NODE;
+    case ON_GAUSS_NE:
+      medfGeoType=typmai3[(int)ikGeoType];
+      return MED_NODE_ELEMENT;
+    default:
+      throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
+    }
+  return MED_UNDEF_ENTITY_TYPE;
+}
+
 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileField1TSWithoutDAS *fath, int meshCsit, int meshIteration, int meshOrder)
 {
   return new MEDFileFieldPerMesh(fath,meshCsit,meshIteration,meshOrder);
@@ -319,6 +343,14 @@ void MEDFileFieldPerMesh::finishLoading(med_idt fid) throw(INTERP_KERNEL::Except
           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
           _field_pm_pt.back()->finishLoading(fid);
         }
+      nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
+      if(nbProfile>0)
+        {
+          _field_pm_pt.resize(_field_pm_pt.size()+1);
+          _field_pm_pt.back()=MEDFileFieldPerMeshPerType::New(this,ON_GAUSS_NE,typmai2[i]);
+          _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
+          _field_pm_pt.back()->finishLoading(fid);
+        }
     }
   int nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
   if(nbProfile>0)
index b42ae5cff2d9f064d8031bf082e41d16e3c1d806..df380a82a6d2ef842c2bd0ba0c20b22fb9669455 100644 (file)
@@ -116,6 +116,7 @@ namespace ParaMEDMEM
     std::vector<std::string> getLocsReallyUsed() const;
     bool isOnNode(int& type, int& number, const DataArrayInt* &arrs) const throw(INTERP_KERNEL::Exception);
     bool isOnCell(int dimDimReq, int& type, int& number, const DataArrayInt* &arrs) const throw(INTERP_KERNEL::Exception);
+    static med_entity_type ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType);
   private:
     MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception);
   private:
index 3e06f29145c1be7b386becfbd0e2ed0c29c5bac3..fe693f6992a2cbf319c2a0b9529472c11943a439 100644 (file)
@@ -354,6 +354,13 @@ class MEDLoaderTest(unittest.TestCase):
         ff=MEDFileFieldMultiTS.New("Pyfile13.med","MyFirstFieldOnGaussPoint")
         ff.write("Pyfile13_bis.med",0)
         pass
+
+    def testMEDField4(self):
+        mm=MEDFileMesh.New("Pyfile14.med")
+        mm.write("Pyfile14_bis.med",2)
+        ff=MEDFileFieldMultiTS.New("Pyfile14.med","MyFieldOnGaussNE")
+        ff.write("Pyfile14_bis.med",0)
+        pass
     
     pass