]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
MGAdapt: allow using float field. Fixes test 13. cbr/mgadapt_float_field
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Wed, 22 Sep 2021 12:56:57 +0000 (14:56 +0200)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Wed, 22 Sep 2021 12:56:57 +0000 (14:56 +0200)
doc/salome/examples/MGAdaptTests_without_session.py
src/SMESH/MG_ADAPT.cxx

index aa3f087a2afacb56bcd65464db71906edfd9bb7b..2f0621d703125b2472c63c0893e1231f25d939a5 100644 (file)
@@ -450,7 +450,7 @@ if __name__ == "__main__" :
   L_OPTIONS.append("05")
   L_OPTIONS.append("06")
   L_OPTIONS.append("08")
-  #L_OPTIONS.append("13")
+  L_OPTIONS.append("13")
 
 # 2. Lancement de la classe
 
index 8f2a36a44f25b9be1fbb7a83dd88ed959cf6ce5f..6253f497574ce5d49293e631bad06802edfcd8cd 100644 (file)
@@ -1381,8 +1381,17 @@ void MgAdapt::convertMedFile(std::string& meshFormatMeshFileName, std::string& s
     checkTimeStepRank(medFileIn) ;
     MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeFieldMultiTS> fts( mfd->getFields()->getFieldWithName(fieldName) );
     MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeField1TS> f = fts->getTimeStep(timeStep, rank);
-    MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> tmFts = MEDCoupling::MEDFileFieldMultiTS::New();
-    tmFts->pushBackTimeStep(f);
+    MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> tmFts = MEDCoupling::DynamicCast<MEDCoupling::MEDFileAnyTypeFieldMultiTS,MEDCoupling::MEDFileFieldMultiTS>(fts);
+
+    // if not able to cast to double field, try float field
+    if (!tmFts)
+    {
+      MEDCoupling::MCAuto<MEDCoupling::MEDFileFloatFieldMultiTS>  tmFtsFloat = MEDCoupling::DynamicCast<MEDCoupling::MEDFileAnyTypeFieldMultiTS,MEDCoupling::MEDFileFloatFieldMultiTS>(fts);
+      if (!tmFtsFloat)
+        THROW_SALOME_EXCEPTION("\nUnexpected field type.\n");
+      // convert float field to double
+      tmFts = tmFtsFloat->convertToDouble();
+    }
 
     fields->pushField(tmFts);