MGAdapt: allow using float field. Fixes test 13.

This commit is contained in:
Christophe Bourcier 2021-09-22 14:56:57 +02:00
parent 7aedadbe42
commit 06613d617e
2 changed files with 12 additions and 3 deletions

View File

@ -450,7 +450,7 @@ if __name__ == "__main__" :
L_OPTIONS.append("05") L_OPTIONS.append("05")
L_OPTIONS.append("06") L_OPTIONS.append("06")
L_OPTIONS.append("08") L_OPTIONS.append("08")
#L_OPTIONS.append("13") L_OPTIONS.append("13")
# 2. Lancement de la classe # 2. Lancement de la classe

View File

@ -1381,8 +1381,17 @@ void MgAdapt::convertMedFile(std::string& meshFormatMeshFileName, std::string& s
checkTimeStepRank(medFileIn) ; checkTimeStepRank(medFileIn) ;
MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeFieldMultiTS> fts( mfd->getFields()->getFieldWithName(fieldName) ); MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeFieldMultiTS> fts( mfd->getFields()->getFieldWithName(fieldName) );
MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeField1TS> f = fts->getTimeStep(timeStep, rank); MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeField1TS> f = fts->getTimeStep(timeStep, rank);
MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> tmFts = MEDCoupling::MEDFileFieldMultiTS::New(); MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> tmFts = MEDCoupling::DynamicCast<MEDCoupling::MEDFileAnyTypeFieldMultiTS,MEDCoupling::MEDFileFieldMultiTS>(fts);
tmFts->pushBackTimeStep(f);
// 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); fields->pushField(tmFts);