-// Copyright (C) 2020-2021 CEA/DEN, EDF R&D
+// Copyright (C) 2020-2023 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <Utils_SALOME_Exception.hxx>
#include <Basics_Utils.hxx>
+#include "SMESH_TypeDefs.hxx"
#ifndef WIN32
#include <unistd.h> // getpid()
#include <fcntl.h>
#include <array>
#include <memory> // unique_ptr
+#include <chrono>
typedef SMESH_Comment ToComment;
}
void MgAdapt::setMedFileIn(std::string fileName)
{
- if ( isFileExist(fileName) )
+ if ( isFileExist( fileName ))
{
medFileIn = fileName;
cmd+= " --in "+ meshIn;
meshFormatOutputMesh = getFileName()+".mesh";
tmpFilesToBeDeleted.push_back(meshFormatOutputMesh);
+
cmd+= " --out "+ meshFormatOutputMesh;
if (useLocalMap || useConstantValue) cmd+= " --sizemap "+ solFileIn;
else // (useBackgroundMap)
if ( key.empty() )
return ToComment( "Problem with library SalomeMeshGemsKeyGenerator: " + errorTxt );
- cmd += " --key " + key;
+ if ( key!="0" )
+ cmd += " --key " + key;
}
#ifdef WIN32
cmd += " < NUL";
#endif
- // std::cout << "--- cmd :"<< std::endl;
- // std::cout << cmd << std::endl;
+
+ if (SALOME::VerbosityActivated())
+ {
+ std::cout << "--- cmd :"<< std::endl;
+ std::cout << cmd << std::endl;
+ }
return cmd;
}
{
aTmpDir = Tmp_dir;
}
- else {
+
+ if ( ! isFileExist( aTmpDir ))
+ {
#ifdef WIN32
aTmpDir = "C:\\";
#else
aGenericName << _getpid();
#endif
aGenericName << "_";
- aGenericName << std::abs((int)(long) aGenericName.data());
+ aGenericName << std::chrono::system_clock::now().time_since_epoch().count();
return aGenericName;
}
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);
_errorMessages.push_back( msg );
//~MESSAGE(msg);
-#ifdef _DEBUG_
- std::cout << msg << std::endl;
-#endif
+ if (SALOME::VerbosityActivated())
+ std::cout << msg << std::endl;
+
return ( _status = isFatal ? MgAdapt::DRS_FAIL : MgAdapt::DRS_WARN_SKIP_ELEM );
}