X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FTools%2Fpadder%2Funittests%2Fusecase_meshJobManager.py;h=4fe3da6d91f45bcf060e8cea72607de816a596fa;hb=10191484fe88a27e962b8e4b57e09d390d8705c7;hp=fadfd403f99f3c05f699f8b8dbafab6fd45893a6;hpb=1067ffa6e7e5c394e3a1b17219d8b355a57607cd;p=modules%2Fsmesh.git diff --git a/src/Tools/padder/unittests/usecase_meshJobManager.py b/src/Tools/padder/unittests/usecase_meshJobManager.py index fadfd403f..4fe3da6d9 100644 --- a/src/Tools/padder/unittests/usecase_meshJobManager.py +++ b/src/Tools/padder/unittests/usecase_meshJobManager.py @@ -1,10 +1,10 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2011-2012 EDF R&D +# Copyright (C) 2011-2016 EDF R&D # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either -# version 2.1 of the License. +# version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -17,12 +17,15 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + # Author(s): Guillaume Boulant (23/03/2011) # # This script illustrates the standard use case of the component # MeshJobManager from within a SALOME script. It could be used as a -# unit test of the component. +# unit test of the component. The typical procedure is: +# $ /runAppli -t +# $ /runSession /usecase_meshJobManager.py # # ======================================================================= @@ -32,7 +35,7 @@ import sys import os import time -from salome.smesh.spadder.configreader import ConfigReader, printConfig +from salome.smesh.spadder.configreader import ConfigReader, printConfig, getPadderTestDir configReader = ConfigReader() defaultConfig = configReader.getDefaultConfig() @@ -70,72 +73,80 @@ component.configure(configId,config) # for testing the component. The test function number corresponds to # the number of the test defined in the SpherePadder installation # directory. - +PADDERTESTDIR = getPadderTestDir(defaultConfig) +#PADDERTESTDIR = spadder.getTestPadderDataDir() +# +# WARN: the above instruction (spadder.getTestPadderDataDir()) +# localizes the PADDERTEST DIR using the PADDERDIR shell variable, +# while the previous one (getPadderTestDir) localizes this directory +# from data of the config (read from the configuration file +# padder.cfg). +# def test00_parameters(): - """Test using a concrete mesh and a single steelbar mesh""" + """Test using a concrete mesh and a single steelbar mesh""" file_concrete=os.path.join(spadder.getTestDataDir(),"concrete.med") file_steelbar=os.path.join(spadder.getTestDataDir(),"ferraill.med") - meshJobParameterList = [] - param = MESHJOB.MeshJobParameter(file_name=file_concrete, + meshJobFileList = [] + param = MESHJOB.MeshJobFile(file_name=file_concrete, file_type=MESHJOB.MED_CONCRETE, group_name="concrete") - meshJobParameterList.append(param) + meshJobFileList.append(param) - param = MESHJOB.MeshJobParameter(file_name=file_steelbar, + param = MESHJOB.MeshJobFile(file_name=file_steelbar, file_type=MESHJOB.MED_STEELBAR, group_name="steelbar") - meshJobParameterList.append(param) - return meshJobParameterList + meshJobFileList.append(param) + return meshJobFileList def test01_parameters(): """One concrete mesh and two steelbar meshes""" - datadir = os.path.join(spadder.getTestPadderDataDir(),"test01") - meshJobParameterList = [] + datadir = os.path.join(PADDERTESTDIR,"test01") + meshJobFileList = [] medfile = os.path.join(datadir,"concrete.med") - param = MESHJOB.MeshJobParameter(file_name=medfile, + param = MESHJOB.MeshJobFile(file_name=medfile, file_type=MESHJOB.MED_CONCRETE, group_name="concrete") - meshJobParameterList.append(param) - + meshJobFileList.append(param) + medfile = os.path.join(datadir,"ferraill.med") - param = MESHJOB.MeshJobParameter(file_name=medfile, + param = MESHJOB.MeshJobFile(file_name=medfile, file_type=MESHJOB.MED_STEELBAR, group_name="ferraill") - meshJobParameterList.append(param) + meshJobFileList.append(param) medfile = os.path.join(datadir,"ferrtran.med") - param = MESHJOB.MeshJobParameter(file_name=medfile, + param = MESHJOB.MeshJobFile(file_name=medfile, file_type=MESHJOB.MED_STEELBAR, group_name="ferrtran") - meshJobParameterList.append(param) - - return meshJobParameterList + meshJobFileList.append(param) + + return meshJobFileList def test02_parameters(): """One steelbar mesh only, without a concrete mesh""" - datadir = os.path.join(spadder.getTestPadderDataDir(),"test02") - meshJobParameterList = [] + datadir = os.path.join(PADDERTESTDIR,"test02") + meshJobFileList = [] medfile = os.path.join(datadir,"cadreef.med") - param = MESHJOB.MeshJobParameter(file_name=medfile, + param = MESHJOB.MeshJobFile(file_name=medfile, file_type=MESHJOB.MED_STEELBAR, group_name="cadre") - meshJobParameterList.append(param) - return meshJobParameterList + meshJobFileList.append(param) + return meshJobFileList def test03_parameters(): """One concrete mesh only, without a steelbar mesh""" - datadir = os.path.join(spadder.getTestPadderDataDir(),"test03") - meshJobParameterList = [] + datadir = os.path.join(PADDERTESTDIR,"test03") + meshJobFileList = [] medfile = os.path.join(datadir,"concrete.med") - param = MESHJOB.MeshJobParameter(file_name=medfile, + param = MESHJOB.MeshJobFile(file_name=medfile, file_type=MESHJOB.MED_CONCRETE, group_name="concrete") - meshJobParameterList.append(param) - return meshJobParameterList + meshJobFileList.append(param) + return meshJobFileList # # ======================================================================= @@ -144,25 +155,31 @@ def test03_parameters(): # # Choose here the use case -#meshJobParameterList = test00_parameters() -#meshJobParameterList = test01_parameters() -#meshJobParameterList = test02_parameters() -meshJobParameterList = test03_parameters() +#meshJobFileList = test00_parameters() +#meshJobFileList = test01_parameters() +#meshJobFileList = test02_parameters() +meshJobFileList = test03_parameters() + +meshJobParameterList = [] +param = MESHJOB.MeshJobParameter(name="RmaxRmin",value="1.5") +meshJobParameterList.append(param) +param = MESHJOB.MeshJobParameter(name="NbIteration",value="3") +meshJobParameterList.append(param) # # Prepare, start and follow-up the job # -jobid = component.initialize(meshJobParameterList, configId) +jobid = component.initialize(meshJobFileList, meshJobParameterList, configId) if jobid<0: msg = component.getLastErrorMessage() - print "ERR: %s"%msg + print("ERR: %s"%msg) sys.exit(1) - + created = False nbiter = 0 while not created: state = component.getState(jobid) - print "MeshJobManager ["+str(nbiter)+"] : state = "+str(state) + print("MeshJobManager ["+str(nbiter)+"] : state = "+str(state)) if state == "CREATED": created = True time.sleep(0.5) @@ -179,10 +196,10 @@ while not created: ok=component.start(jobid) if not ok: msg = component.getLastErrorMessage() - print "ERR: %s"%msg + print("ERR: %s"%msg) sys.exit(1) -print "job started: %s"%ok +print("job started: %s"%ok) # # This part illustrates how you can follow the execution of the job. @@ -195,18 +212,20 @@ ended = False nbiter = 0 while not ended: state = component.getState(jobid) - print "MeshJobManager ["+str(nbiter)+"] : state = "+str(state) + print("MeshJobManager ["+str(nbiter)+"] : state = "+str(state)) if state not in run_states: ended=True time.sleep(0.5) nbiter+=1 - + if state not in end_states: - print "ERR: jobid = "+str(jobid)+" ended abnormally with state="+str(state) + print("ERR: jobid = "+str(jobid)+" ended abnormally with state="+str(state)) msg = component.getLastErrorMessage() - print "ERR: %s"%msg + print("ERR: %s"%msg) else: - print "OK: jobid = "+str(jobid)+" ended with state="+str(state) + print("OK: jobid = "+str(jobid)+" ended with state="+str(state)) meshJobResults = component.finalize(jobid) - print meshJobResults - print "You will find the results files in the directory:\n%s"%meshJobResults.results_dirname + print(meshJobResults) + if meshJobResults.status is not True: + print("ERR: the results are not OK: %s"%component.getLastErrorMessage()) + print("ERR: see log files in %s"%meshJobResults.results_dirname)