X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FMG_ADAPT.cxx;h=27a57c894cc24edb5544fa21a0d1b1b1807641dc;hp=1e748c5342aa4359611856a17f63c6c28cb3fa45;hb=HEAD;hpb=772ad1d5f4f1be95a6dd232d7c4af387df7cb88d diff --git a/src/SMESH/MG_ADAPT.cxx b/src/SMESH/MG_ADAPT.cxx index 1e748c534..b7af53ab0 100644 --- a/src/SMESH/MG_ADAPT.cxx +++ b/src/SMESH/MG_ADAPT.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2021 CEA/DEN, EDF R&D +// Copyright (C) 2020-2024 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -33,6 +33,7 @@ #include #include +#include "SMESH_TypeDefs.hxx" #ifndef WIN32 #include // getpid() @@ -42,6 +43,7 @@ #include #include #include // unique_ptr +#include typedef SMESH_Comment ToComment; @@ -322,7 +324,7 @@ MgAdaptHypothesisData* MgAdapt::getData() const } void MgAdapt::setMedFileIn(std::string fileName) { - if ( isFileExist(fileName) ) + if ( isFileExist( fileName )) { medFileIn = fileName; @@ -955,6 +957,7 @@ std::string MgAdapt::getCommandToRun() cmd+= " --in "+ meshIn; meshFormatOutputMesh = getFileName()+".mesh"; tmpFilesToBeDeleted.push_back(meshFormatOutputMesh); + cmd+= " --out "+ meshFormatOutputMesh; if (useLocalMap || useConstantValue) cmd+= " --sizemap "+ solFileIn; else // (useBackgroundMap) @@ -1035,14 +1038,19 @@ std::string MgAdapt::getCommandToRun() 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; } @@ -1094,7 +1102,9 @@ std::string MgAdapt::defaultWorkingDirectory() { aTmpDir = Tmp_dir; } - else { + + if ( ! isFileExist( aTmpDir )) + { #ifdef WIN32 aTmpDir = "C:\\"; #else @@ -1127,7 +1137,7 @@ std::string MgAdapt::getFileName() const aGenericName << _getpid(); #endif aGenericName << "_"; - aGenericName << std::abs((int)(long) aGenericName.data()); + aGenericName << std::chrono::system_clock::now().time_since_epoch().count(); return aGenericName; } @@ -1401,8 +1411,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); @@ -1563,9 +1582,9 @@ MgAdapt::Status MgAdapt::addMessage(const std::string& msg, _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 ); }