SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test)
INSTALL(FILES ${GOOD_TESTS} ${BAD_TESTS} ${SESSION_FREE_TESTS} DESTINATION ${TEST_INSTALL_DIRECTORY})
-INSTALL(FILES Mesh_tri.med DESTINATION ${TEST_INSTALL_DIRECTORY})
+INSTALL(FILES Mesh_tri.med test_homard_adapt.med DESTINATION ${TEST_INSTALL_DIRECTORY})
INSTALL(FILES CTestTestfileInstall.cmake
DESTINATION ${TEST_INSTALL_DIRECTORY}
--- /dev/null
+#!/usr/bin/env python3
+
+
+
+import salome
+salome.salome_init()
+
+import SMESH, SALOMEDS
+from salome.smesh import smeshBuilder
+import SMESHHOMARD
+
+smesh = smeshBuilder.New()
+
+import os, inspect, tempfile, shutil
+
+data_dir = os.path.dirname(inspect.getfile(lambda: None))
+working_dir = tempfile.mkdtemp()
+
+input_med = os.path.join (data_dir, "test_homard_adapt.med")
+output_med_1 = os.path.join (working_dir, "test_1.00_Uniform_R_01.med")
+output_med_2 = os.path.join (working_dir, "test_1.00_Uniform_R_02.med")
+log_file_1 = os.path.join (working_dir, "test_1.00_Uniform_R_01.med.log")
+log_file_2 = os.path.join (working_dir, "test_1.00_Uniform_R_02.med.log")
+
+# Case 1: input: med file
+# output: med file, log file, published mesh
+if os.path.isfile(output_med_1):
+ os.remove(output_med_1)
+if os.path.isfile(log_file_1):
+ os.remove(log_file_1)
+
+smeshhomard = smesh.Adaptation("Uniform")
+Case_1 = smeshhomard.CreateCase("MAILL", input_med, working_dir)
+Case_1.SetConfType(0)
+smeshhomard.SetKeepMedOUT(True)
+smeshhomard.SetPublishMeshOUT(True)
+smeshhomard.SetMeshNameOUT("MAILL_Uniform_R_01")
+smeshhomard.SetMeshFileOUT(output_med_1)
+smeshhomard.SetKeepWorkingFiles(False)
+smeshhomard.SetLogInFile(True)
+smeshhomard.SetLogFile(log_file_1)
+smeshhomard.SetRemoveLogOnSuccess(False)
+smeshhomard.SetVerboseLevel(3)
+smeshhomard.Compute()
+
+if os.path.isfile(output_med_1):
+ os.remove(output_med_1)
+else:
+ print("Test Uniform refinement Case 1: Error: no output med file")
+ assert(False)
+
+if os.path.isfile(log_file_1):
+ os.remove(log_file_1)
+else:
+ print("Test Uniform refinement Case 1: Error: no log file")
+ assert(False)
+
+# Case 2: input: mesh, boundaries
+# output: published mesh
+if os.path.isfile(output_med_2):
+ os.remove(output_med_2)
+if os.path.isfile(log_file_2):
+ os.remove(log_file_2)
+
+# prepare input mesh
+([MAILL], status) = smesh.CreateMeshesFromMED( input_med )
+
+#smeshhomard = smesh.Adaptation("Uniform")
+Boun_1 = smeshhomard.CreateBoundaryCylinder("Boun_1", 0.5, 0.5, 0.5, 0, 0, 1, 0.25)
+Case_1 = smeshhomard.CreateCaseOnMesh("MAILL", MAILL.GetMesh(), working_dir)
+Case_1.SetConfType(0)
+Case_1.AddBoundaryGroup("Boun_1", "BORD_EXT")
+Case_1.AddBoundaryGroup("Boun_1", "MOITIE1")
+smeshhomard.SetKeepMedOUT(False)
+smeshhomard.SetPublishMeshOUT(True)
+smeshhomard.SetMeshNameOUT("MAILL_Uniform_R_02")
+smeshhomard.SetMeshFileOUT(output_med_2)
+smeshhomard.SetKeepWorkingFiles(False)
+smeshhomard.SetLogInFile(True)
+smeshhomard.SetLogFile(log_file_2)
+smeshhomard.SetRemoveLogOnSuccess(True)
+smeshhomard.SetVerboseLevel(0)
+smeshhomard.Compute()
+
+if os.path.isfile(output_med_2):
+ print("Test Uniform refinement Case 2: Error: output med file has not been removed")
+ assert(False)
+
+if os.path.isfile(log_file_2):
+ print("Test Uniform refinement Case 2: Error: log file has not been removed")
+ assert(False)
+
+shutil.rmtree(working_dir)
+
+if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser()
test_smeshplugin_mg_tetra_parallele.py
test_smeshplugins.py
MGAdaptTests_without_session.py
+ test_homard_adapt.py
blocFissure_01_without_session.py
blocFissure_02_without_session.py
blocFissure_03_without_session.py
_Texte( "" ), _bLu( false )
{
MESSAGE("siter = "<<siter<<", siterp1 = "<<siterp1);
-// Le repertoire ou se trouve l'executable HOMARD
+ // Le repertoire ou se trouve l'executable HOMARD
std::string dir ;
- if ( getenv("HOMARD_REP_EXE_PRIVATE") != NULL ) { dir = getenv("HOMARD_REP_EXE_PRIVATE") ; }
- else { dir = getenv("HOMARD_REP_EXE") ; }
+ // TODO?
+ if ( getenv("HOMARD_ROOT_DIR") != NULL ) { dir = getenv("HOMARD_ROOT_DIR") ; }
+ dir += "/bin/salome";
MESSAGE("dir ="<<dir);
-// L'executable HOMARD
- std::string executable ;
- if ( getenv("HOMARD_EXE_PRIVATE") != NULL ) { executable = getenv("HOMARD_EXE_PRIVATE") ; }
- else { executable = getenv("HOMARD_EXE") ; }
+ // L'executable HOMARD
+ std::string executable = "homard";
MESSAGE("executable ="<<executable);
-// Memorisation du nom complet de l'executable HOMARD
+ // Memorisation du nom complet de l'executable HOMARD
_HOMARD_Exec = dir + "/" + executable ;
MESSAGE("==> _HOMARD_Exec ="<<_HOMARD_Exec) ;
-//
+ //
_siter = siter ;
_siterp1 = siterp1 ;
}
myAdvOpt->removeLogOnSuccessCheck ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
myAdvOpt->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" ));
- // disable // TODO???
myAdvOpt->logInFileCheck->setChecked(true);
myAdvOpt->removeLogOnSuccessCheck->setChecked(false);
l->addLayout( btnLayout );
// dialog name and size
- /*
resize(600, 1150);
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(0);
setSizePolicy(sizePolicy);
setMinimumSize(QSize(600, 320));
setSizeIncrement(QSize(1, 1));
- setBaseSize(QSize(600, 320));
+ setBaseSize(QSize(600, 600));
setAutoFillBackground(true);
- */
SetBoundaryNo();
InitConnect();
connect( buttonHelp, SIGNAL(pressed()), this, SLOT(PushOnHelp()));
connect(myArgs, SIGNAL(updateSelection()), this, SLOT(updateSelection()));
- connect(myArgs, SIGNAL(toExportMED(const char*)), this, SLOT(exportMED(const char*)));
}
//=================================================================================
if (!CheckCase(true))
return false;
- MESSAGE("PushOnApply: *** aaajfa *** 12");
-
// Create boundaries
if (myArgs->RBBoundaryCAO->isChecked()) {
QString monBoundaryCAOName = myArgs->CBBoundaryCAO->currentText();
}
}
}
- MESSAGE("PushOnApply: *** aaajfa *** 13");
// Output MED and MESH parameters
myHomardGen->SetKeepMedOUT(myArgs->myOutMedFileChk->isChecked());
MESSAGE("myHomardGen->SetLogFile(" << anOutLog.toStdString().c_str() << ")");
myHomardGen->SetLogFile(anOutLog.toStdString().c_str());
}
- MESSAGE("PushOnApply: *** aaajfa *** 14");
// Compute and publish
bool isSuccess = true;
QObject::tr(CORBA::string_dup(S_ex.details.text)) );
isSuccess = false;
}
- MESSAGE("PushOnApply: *** aaajfa *** 15");
// Update Object Browser
if (isSuccess) {
myAdvOpt->workingDirectoryLineEdit->setReadOnly(false);
myAdvOpt->workingDirectoryPushButton->setEnabled(true);
- MESSAGE("PushOnApply: *** aaajfa *** THE END");
return isSuccess;
}
argumentsLayout->setColumnStretch( 1, 5 );
argumentsLayout->setRowStretch( 4, 5 );
- mySelectInMedFileButton->setText(QString());
+ //mySelectInMedFileButton->setText(QString());
CBBoundaryD->setText(QApplication::translate("CreateCase", "Discrete boundary", nullptr));
CBBoundaryA->setText(QApplication::translate("CreateCase", "Analytical boundary", nullptr));
PBBoundaryCAOEdit->setText(QApplication::translate("CreateCase", "Edit", nullptr));
if ( TypeFichier == "med" ) { filtre = QString("Med") ; }
else if ( TypeFichier == "py" ) { filtre = QString("Python") ; }
else { filtre = TypeFichier ; }
-//
+ //
if ( TypeFichier != "" ) { filtre += QString(" files (*.") + TypeFichier + QString(");;") ; }
-//
+ //
filtre += QString("all (*) ") ;
-//
+ //
// B. Selection
- int nbSel = SMESH_HOMARD_UTILS::IObjectCount() ;
-// MESSAGE("nbSel ="<<nbSel);
+ //int nbSel = SMESH_HOMARD_UTILS::IObjectCount() ;
+ int nbSel = 0;
+ // MESSAGE("nbSel ="<<nbSel);
// B.1. Rien n'est selectionne
if ( nbSel == 0 )
{
-// aFile = QFileDialog::getOpenFileName(0, QObject::tr("HOM_SELECT_FILE_0"), QString(""), QString("Med files (*.med);;all (*) ") );
+ //aFile = QFileDialog::getOpenFileName(0, QObject::tr("HOM_SELECT_FILE_0"), QString(""), QString("Med files (*.med);;all (*) ") );
aFile = QFileDialog::getOpenFileName(0, QObject::tr("HOM_SELECT_FILE_0"), QString(""), filtre );
}
// B.2. Un objet est selectionne
#include "SMESH_Homard_i.hxx"
#include "SMESH_Homard.hxx"
-#include <SMESH_Gen_i.hxx>
+#include "SMESH_Gen_i.hxx"
#include "SMESH_PythonDump.hxx"
+#include "SMESH_File.hxx"
+
+// TODO?
//#include "FrontTrack.hxx"
#include "utilities.h"
_MeshNameOUT(""),
_MeshFileOUT(""),
_LogFile(""),
- _CaseOnMedFile(true)
+ _CaseOnMedFile(true),
+ _SmeshMesh(SMESH::SMESH_Mesh::_nil()),
+ _TmpMeshFile("")
{
MESSAGE("constructor de HOMARD_Gen_i");
myHomard = new SMESHHOMARDImpl::HOMARD_Gen;
//=============================================================================
HOMARD_Gen_i::~HOMARD_Gen_i()
{
+ if (!myCase->_is_nil()) {
+ CleanCase();
+ }
}
//=============================================================================
MESSAGE("CreateCaseOnMesh : smeshMesh is not nil");
// A.3. Write mesh object in a temporary file in the working directory
- std::string aTmpMeshFile (theWorkingDir);
- aTmpMeshFile += std::string("/") + std::string(MeshName) + "_saved_from_SMESH.med"; // TODO: unique
- const char* MeshFile = aTmpMeshFile.c_str();
+ std::string aTmpMeshFile = theWorkingDir;
+ aTmpMeshFile = theWorkingDir;
+ aTmpMeshFile += std::string("/") + std::string(MeshName) + "_saved_from_SMESH";
+ _TmpMeshFile = aTmpMeshFile + ".med";
+ SMESH_File aFile (_TmpMeshFile, false);
+ for (int ii = 1; aFile.exists(); ii++) {
+ _TmpMeshFile = aTmpMeshFile + std::string("_") + std::to_string(ii) + ".med";
+ aFile = SMESH_File(_TmpMeshFile, false);
+ }
+ const char* MeshFile = _TmpMeshFile.c_str();
bool toOverwrite = true;
bool toFindOutDim = true;
// Python Dump
PythonDump();
- // Delete log file, if required
- MESSAGE("myIteration1->GetLogFile() = " << myIteration1->GetLogFile());
- if (_LogInFile && _RemoveLogOnSuccess) {
- // Remove log file on success
- // TODO: QFile(myIteration->GetLogFile()).remove();
- }
-
// Clean all data
CleanCase();
}
void HOMARD_Gen_i::CleanCase()
{
+ // Delete log file, if required
+ MESSAGE("myIteration1->GetLogFile() = " << myIteration1->GetLogFile());
+ if (_LogInFile && _RemoveLogOnSuccess) {
+ // Remove log file on success
+ SMESH_File(myIteration1->GetLogFile(), false).remove();
+ }
+
// Delete all boundaries
std::map<std::string, SMESHHOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
for (it_boundary = _mesBoundarys.begin();
// Delete case
DeleteCase();
+
+ // Delete tmp mesh file
+ if (!_CaseOnMedFile && !_TmpMeshFile.empty()) {
+ SMESH_File aFile (_TmpMeshFile, false);
+ if (aFile.exists()) aFile.remove();
+ }
+ _SmeshMesh = SMESH::SMESH_Mesh::_nil();
}
//=============================================================================
// C. Lancement des projections
MESSAGE (". Lancement des projections");
+ // TODO?
//FrontTrack* myFrontTrack = new FrontTrack();
//myFrontTrack->track(theInputMedFile, theOutputMedFile, theInputNodeFiles, theXaoFileName, theIsParallel);
SALOMEDS::SObject_var aSmeshSO =
SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindComponent("SMESH");
//
+ // TODO?
+ // Temporary suppressed depublication of mesh with the same name of file
+ /*
if (!CORBA::is_nil(aSmeshSO)) {
// On verifie que le fichier n est pas deja publie
SALOMEDS::ChildIterator_var aIter =
}
}
}
+ */
// On enregistre le fichier
MESSAGE("Enregistrement du fichier");
//
//SMESH::SMESH_Gen_var aSmeshEngine = this->retrieveSMESHInst();
SMESH_Gen_i* aSmeshEngine = SMESH_Gen_i::GetSMESHGen();
- MESSAGE(" *** aaajfa *** !!! 1");
//
//ASSERT(!CORBA::is_nil(aSmeshEngine));
aSmeshEngine->UpdateStudy();
SMESH::DriverMED_ReadStatus theStatus;
// On met a jour les attributs AttributeExternalFileDef et AttributePixMap
- MESSAGE(" *** aaajfa *** !!! 2");
SMESH::mesh_array* mesMaillages = aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
- MESSAGE(" *** aaajfa *** !!! 3");
if (CORBA::is_nil(aSmeshSO)) {
aSmeshSO = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindComponent("SMESH");
if (CORBA::is_nil(aSmeshSO)) return;
}
- MESSAGE(" *** aaajfa *** !!! 4");
for (int i = 0; i < (int)mesMaillages->length(); i++) {
MESSAGE(". Mise a jour des attributs du maillage");
else { icone = "mesh_tree_mesh.png"; }
anAttr2->SetPixMap(icone);
}
- MESSAGE(" *** aaajfa *** !!! 5");
}
//=============================================================================
// SMESH_Homard
pd << "import SMESHHOMARD\n";
- pd << "smeshhomard = " << SMESH_Gen_i::GetSMESHGen() << ".CreateHOMARD_ADAPT()\n";
+ //pd << "smeshhomard = " << SMESH_Gen_i::GetSMESHGen() << ".CreateHOMARD_ADAPT()\n";
+ pd << "smeshhomard = " << SMESH_Gen_i::GetSMESHGen() << ".Adaptation(\"Uniform\")\n";
// Boundaries
if (_mesBoundarys.size() > 0) MESSAGE(". Creation of the boundaries");
else {
pd << "Case_1 = smeshhomard.CreateCaseOnMesh(\"" << myIteration0->GetMeshName();
pd << "\", " << _SmeshMesh;
- pd << ", \"" << myCase->GetDirName() << "\")\n";
+ pd << ".GetMesh(), \"" << myCase->GetDirName() << "\")\n";
}
pd << myCase->GetDumpPython();
// Preferences
- pd << "smeshhomard.SetKeepMedOUT(" << _KeepMedOUT << ")\n";
- pd << "smeshhomard.SetPublishMeshOUT(" << _PublishMeshOUT << ")\n";
+ pd << "smeshhomard.SetKeepMedOUT(" << (_KeepMedOUT ? "True" : "False") << ")\n";
+ pd << "smeshhomard.SetPublishMeshOUT(" << (_PublishMeshOUT ? "True" : "False") << ")\n";
pd << "smeshhomard.SetMeshNameOUT(\"" << _MeshNameOUT << "\")\n";
pd << "smeshhomard.SetMeshFileOUT(\"" << _MeshFileOUT << "\")\n";
- pd << "smeshhomard.SetKeepWorkingFiles(" << _KeepWorkingFiles << ")\n";
- pd << "smeshhomard.SetLogInFile(" << _LogInFile << ")\n";
+ pd << "smeshhomard.SetKeepWorkingFiles(" << (_KeepWorkingFiles ? "True" : "False") << ")\n";
+ pd << "smeshhomard.SetLogInFile(" << (_LogInFile ? "True" : "False") << ")\n";
if (_LogInFile) pd << "smeshhomard.SetLogFile(\"" << _LogFile << "\")\n";
- pd << "smeshhomard.SetRemoveLogOnSuccess(" << _RemoveLogOnSuccess << ")\n";
+ pd << "smeshhomard.SetRemoveLogOnSuccess(" << (_RemoveLogOnSuccess ? "True" : "False") << ")\n";
pd << "smeshhomard.SetVerboseLevel(" << _VerboseLevel << ")\n";
// Compute
// Input data type
bool _CaseOnMedFile;
SMESH::SMESH_Mesh_var _SmeshMesh;
+ std::string _TmpMeshFile;
};
SMESH_I_EXPORT std::vector<double> GetBoundingBoxInMedFile(const char * aFile);