From e0b3420d8b0c77fc800bd281c206bb3662b1de2d Mon Sep 17 00:00:00 2001 From: Christophe Bourcier Date: Wed, 15 Sep 2021 16:33:31 +0200 Subject: [PATCH] Fix crash in Interpolate if the field is float --- src/MEDCalc/cmp/MEDDataManager_i.cxx | 10 ++++++++++ src/MEDCalc/cmp/MEDDataManager_i.hxx | 1 + 2 files changed, 11 insertions(+) diff --git a/src/MEDCalc/cmp/MEDDataManager_i.cxx b/src/MEDCalc/cmp/MEDDataManager_i.cxx index 756b529b9..cb4127df5 100644 --- a/src/MEDCalc/cmp/MEDDataManager_i.cxx +++ b/src/MEDCalc/cmp/MEDDataManager_i.cxx @@ -722,6 +722,16 @@ MEDCouplingFieldDouble * MEDDataManager_i::getFieldDouble(const MEDCALC::FieldHa fieldHandler->iteration, fieldHandler->order)); MCAuto myField(DynamicCast(myFieldTmpp)); + + // trying float field + if (!myField){ + MCAuto myFieldFloat(DynamicCast(myFieldTmpp)); + if (myFieldFloat){ + myField = myFieldFloat->convertToDblField(); + LOG("getFieldDouble: field "<fieldname<<" was read as float and converted to double."); + } + } + myField->setMesh(myMesh); _fieldDoubleMap[fieldHandler->id] = myField.retn(); return myField; diff --git a/src/MEDCalc/cmp/MEDDataManager_i.hxx b/src/MEDCalc/cmp/MEDDataManager_i.hxx index f6081f08e..ff1ecfa44 100644 --- a/src/MEDCalc/cmp/MEDDataManager_i.hxx +++ b/src/MEDCalc/cmp/MEDDataManager_i.hxx @@ -29,6 +29,7 @@ #include "MEDCouplingRemapper.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingFieldFloat.hxx" using namespace MEDCoupling; /*! This map is used for lifecycle management of fields used in this operator */ -- 2.39.2