From 37d8c5a41ce1ba24b5cae45cf8e15e8e169595f8 Mon Sep 17 00:00:00 2001 From: GERALD NICOLAS Date: Thu, 11 Feb 2021 10:35:50 +0100 Subject: [PATCH] =?utf8?q?contr=C3=B4les?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/SMESH/MG_ADAPT.cxx | 69 ++++++++++++++++++++++++++++-------------- src/SMESH/MG_ADAPT.hxx | 5 +-- 2 files changed, 49 insertions(+), 25 deletions(-) diff --git a/src/SMESH/MG_ADAPT.cxx b/src/SMESH/MG_ADAPT.cxx index d22075995..66ab95aa1 100644 --- a/src/SMESH/MG_ADAPT.cxx +++ b/src/SMESH/MG_ADAPT.cxx @@ -133,7 +133,7 @@ MgAdapt::~MgAdapt() void MgAdapt::buildModel() { - const char* boolOptionNames[] = { "compute_ridges", // yes + const char* boolOptionNames[] = { "compute_ridges", // yes "" // mark of end }; // const char* intOptionNames[] = { "max_number_of_errors_printed", // 1 @@ -143,8 +143,8 @@ void MgAdapt::buildModel() const char* doubleOptionNames[] = { "max_memory", // 0 "" // mark of end }; - const char* charOptionNames[] = { "components", // "yes" - "adaptation", // both + const char* charOptionNames[] = { "components", // "yes" + "adaptation", // both "" // mark of end }; @@ -171,10 +171,10 @@ void MgAdapt::buildModel() // default values to be used while MG-Adapt - _defaultOptionValues["adaptation" ] = "both"; - _defaultOptionValues["components" ] = "outside components"; - _defaultOptionValues["compute_ridges" ] = "yes"; - _defaultOptionValues["max_memory" ] = ToComment(defaultMaximumMemory()); + _defaultOptionValues["adaptation" ] = "both"; + _defaultOptionValues["components" ] = "outside components"; + _defaultOptionValues["compute_ridges"] = "yes"; + _defaultOptionValues["max_memory" ] = ToComment(defaultMaximumMemory()); } //============================================================================= @@ -527,6 +527,8 @@ void MgAdapt::setOptionValue(const std::string& optionName, const std::string& optionValue) throw (std::invalid_argument) { +// INFOS("setOptionValue"); +// std::cout << "optionName: " << optionName << ", optionValue: " << optionValue << std::endl; TOptionValues::iterator op_val = _option2value.find(optionName); if (op_val == _option2value.end()) { @@ -586,6 +588,7 @@ throw (std::invalid_argument) std::string value( ptr, i ); if ( _defaultOptionValues[ optionName ] == value ) value.clear(); +// std::cout << "==> value: " << value << std::endl; op_val->second = value; } @@ -594,9 +597,11 @@ throw (std::invalid_argument) //! Return option value. If isDefault provided, it can be a default value, // then *isDefault == true. If isDefault is not provided, the value will be // empty if it equals a default one. -std::string MgAdapt::getOptionValue(const std::string& optionName, bool* isDefault) const +std::string MgAdapt::getOptionValue(const std::string& optionName, bool* isDefault) const throw (std::invalid_argument) { +// INFOS("getOptionValue"); +// std::cout << "optionName: " << optionName << ", isDefault: " << isDefault << std::endl; TOptionValues::const_iterator op_val = _option2value.find(optionName); if (op_val == _option2value.end()) { @@ -615,6 +620,8 @@ throw (std::invalid_argument) op_val = _defaultOptionValues.find( optionName ); if (op_val != _defaultOptionValues.end()) val = op_val->second; } +// std::cout << "==> val: " << val << std::endl; + return val; } //================================================================================ @@ -858,9 +865,11 @@ std::string MgAdapt::getCommandToRun() //~{ //~// constant value TODO //~} - /* sizemap file is not adapted in case of only surface adaptation see MeshGems docs */ std::string adapOp = "adaptation"; std::string adpOpVal = getOptionValue(adapOp); + // Check coherence between mesh dimension and option +// checkDimensionOption(adpOpVal); + /* sizemap file is not adapted in case of only surface adaptation see MeshGems docs */ std::string surfaceAdapt = "surface"; if(surfaceAdapt != adpOpVal ) { @@ -869,10 +878,6 @@ std::string MgAdapt::getCommandToRun() solFormatOutput.push_back(solFileOut); tmpFilesToBeDeleted.push_back(solFileOut); } - if (verbosityLevel != defaultVerboseLevel()) - { - cmd+= " --verbose "+ ToComment(verbosityLevel); - } std::string option, value; bool isDefault; @@ -906,6 +911,12 @@ std::string MgAdapt::getCommandToRun() cmd += option + " " + value; } } + + // Verbosity Level + if (verbosityLevel != defaultVerboseLevel()) + { + cmd+= " --verbose "+ ToComment(verbosityLevel); + } //~} //~cmd+= " >" #ifdef WIN32 @@ -1159,7 +1170,23 @@ std::vector MgAdapt::getListFieldsNames(std::string fileIn) return listFieldsNames ; } -bool MgAdapt::checkFieldName(std::string fileIn) +void MgAdapt::checkDimensionOption(std::string adpOpVal) +{ + // Pas correct. + MEDCoupling::MCAuto mfd = MEDCoupling::MEDFileData::New(medFileIn); + int meshdim = mfd->getMeshes()->getMeshAtPos(0)->getMeshDimension() ; + + if ( ( meshdim == 2 ) & ( adpOpVal != "surface" ) ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text = "Mesh dimension is 2; the option should be 'surface' instead of '" + adpOpVal + "'." ; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + } +} + +void MgAdapt::checkFieldName(std::string fileIn) { bool ret = false ; std::vector listFieldsNames = getListFieldsNames(fileIn); @@ -1183,10 +1210,9 @@ bool MgAdapt::checkFieldName(std::string fileIn) es.text = CORBA::string_dup(text.c_str()); throw SALOME::SALOME_Exception(es); } - return ret ; } -bool MgAdapt::checkTimeStepRank(std::string fileIn) +void MgAdapt::checkTimeStepRank(std::string fileIn) { bool ret = false ; MEDCoupling::MCAuto mfd = MEDCoupling::MEDFileData::New(fileIn); @@ -1215,7 +1241,6 @@ bool MgAdapt::checkTimeStepRank(std::string fileIn) es.text = CORBA::string_dup(text.c_str()); throw SALOME::SALOME_Exception(es); } - return ret ; } void MgAdapt::convertMedFile(std::string& meshFormatMeshFileName, std::string& solFormatFieldFileName, std::string& meshFormatsizeMapFile) @@ -1236,18 +1261,16 @@ void MgAdapt::convertMedFile(std::string& meshFormatMeshFileName, std::string& s if (useBackgroundMap) { - bool ret ; - ret = checkFieldName(sizeMapFile) ; - ret = checkTimeStepRank(sizeMapFile) ; + checkFieldName(sizeMapFile) ; + checkTimeStepRank(sizeMapFile) ; meshFormatsizeMapFile = getFileName(); meshFormatsizeMapFile += ".mesh"; buildBackGroundMeshAndSolFiles(fieldFileNames, meshFormatsizeMapFile); } else if(useLocalMap) { - bool ret ; - ret = checkFieldName(medFileIn) ; - ret = checkTimeStepRank(medFileIn) ; + checkFieldName(medFileIn) ; + checkTimeStepRank(medFileIn) ; MEDCoupling::MCAuto fts = dynamic_cast( mfd->getFields()->getFieldWithName(fieldName) ); MEDCoupling::MCAuto f = fts->getTimeStep(timeStep, rank); MEDCoupling::MCAuto tmFts = MEDCoupling::MEDFileFieldMultiTS::New(); diff --git a/src/SMESH/MG_ADAPT.hxx b/src/SMESH/MG_ADAPT.hxx index 9364add29..68f699baf 100644 --- a/src/SMESH/MG_ADAPT.hxx +++ b/src/SMESH/MG_ADAPT.hxx @@ -329,8 +329,9 @@ private : void cleanUp(); void appendMsgToLogFile(std::string& msg); std::vector getListFieldsNames(std::string fileIn) ; - bool checkFieldName(std::string fileIn) ; - bool checkTimeStepRank(std::string fileIn) ; + void checkDimensionOption(std::string adpOpVal) ; + void checkFieldName(std::string fileIn) ; + void checkTimeStepRank(std::string fileIn) ; }; -- 2.39.2