From 06613d617eb0569112b6a803cbb8b4bdeed241b9 Mon Sep 17 00:00:00 2001 From: Christophe Bourcier Date: Wed, 22 Sep 2021 14:56:57 +0200 Subject: [PATCH] MGAdapt: allow using float field. Fixes test 13. --- doc/salome/examples/MGAdaptTests_without_session.py | 2 +- src/SMESH/MG_ADAPT.cxx | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/salome/examples/MGAdaptTests_without_session.py b/doc/salome/examples/MGAdaptTests_without_session.py index aa3f087a2..2f0621d70 100644 --- a/doc/salome/examples/MGAdaptTests_without_session.py +++ b/doc/salome/examples/MGAdaptTests_without_session.py @@ -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 diff --git a/src/SMESH/MG_ADAPT.cxx b/src/SMESH/MG_ADAPT.cxx index 8f2a36a44..6253f4975 100644 --- a/src/SMESH/MG_ADAPT.cxx +++ b/src/SMESH/MG_ADAPT.cxx @@ -1381,8 +1381,17 @@ void MgAdapt::convertMedFile(std::string& meshFormatMeshFileName, std::string& s checkTimeStepRank(medFileIn) ; MEDCoupling::MCAuto fts( mfd->getFields()->getFieldWithName(fieldName) ); MEDCoupling::MCAuto f = fts->getTimeStep(timeStep, rank); - MEDCoupling::MCAuto tmFts = MEDCoupling::MEDFileFieldMultiTS::New(); - tmFts->pushBackTimeStep(f); + MEDCoupling::MCAuto tmFts = MEDCoupling::DynamicCast(fts); + + // if not able to cast to double field, try float field + if (!tmFts) + { + MEDCoupling::MCAuto tmFtsFloat = MEDCoupling::DynamicCast(fts); + if (!tmFtsFloat) + THROW_SALOME_EXCEPTION("\nUnexpected field type.\n"); + // convert float field to double + tmFts = tmFtsFloat->convertToDouble(); + } fields->pushField(tmFts); -- 2.39.2