]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Ajout du premier test avec Aster
authorAndré Ribes <andre.ribes@edf.fr>
Wed, 30 Jun 2010 14:42:30 +0000 (16:42 +0200)
committerAndré Ribes <andre.ribes@edf.fr>
Wed, 30 Jun 2010 14:42:30 +0000 (16:42 +0200)
Il faut encore faire le code

15 files changed:
configure.ac
src/daSalome/daYacsSchemaCreator/infos_daComposant.py
src/tests/daSalome/Makefile.am
src/tests/daSalome/test_aster_zzzz159a.py.in [new file with mode: 0644]
src/tests/daSalome/test_aster_zzzz159a_aster_functions.py [new file with mode: 0644]
src/tests/daSalome/test_aster_zzzz159a_background.py [new file with mode: 0644]
src/tests/daSalome/test_aster_zzzz159a_background_error.py [new file with mode: 0644]
src/tests/daSalome/test_aster_zzzz159a_functions.py [new file with mode: 0644]
src/tests/daSalome/test_aster_zzzz159a_init_algorithm.py [new file with mode: 0644]
src/tests/daSalome/test_aster_zzzz159a_init_parameters.py.in [new file with mode: 0644]
src/tests/daSalome/test_aster_zzzz159a_observation.py [new file with mode: 0644]
src/tests/daSalome/test_aster_zzzz159a_observation_error.py [new file with mode: 0644]
src/tests/daSalome/zzzz159a.3 [new file with mode: 0644]
src/tests/daSalome/zzzz159a.export.esclave.in [new file with mode: 0644]
src/tests/daSalome/zzzz159a.mail [new file with mode: 0644]

index fb45342511c9dc803fe4159f00717b758b235480..a7fe04e9c69cd2bf211cf89d4700fedcc4ebd103 100644 (file)
@@ -116,6 +116,9 @@ AC_CONFIG_FILES([
         src/tests/daSalome/Makefile
         src/tests/daSalome/test000_Blue_AnalysisFile.py
         src/tests/daSalome/test017_3DVAR_par_fonction.py
+        src/tests/daSalome/test_aster_zzzz159a_init_parameters.py
+        src/tests/daSalome/test_aster_zzzz159a.py
+        src/tests/daSalome/zzzz159a.export.esclave
         src/tests/daComposant/Makefile
         src/tests/daComposant/Plateforme/Makefile
         bin/Makefile
index 7e7c2b1557120543b0853798ca18e022e5693cae..06df3c16fd229d24bfdf6f9279c6a3e19b641ab4 100644 (file)
@@ -43,6 +43,7 @@ FromNumpyList["Vector"] = ["String", "Script"]
 FromNumpyList["Matrix"] = ["String", "Script"]
 FromNumpyList["Function"] = ["Dict"]
 FromNumpyList["List"] = ["List"]
+FromNumpyList["Dict"] = ["Script"]
 
 # -- Infos from daAlgorithms --
 AssimAlgos = ["Blue", "EnsembleBlue", "Kalman", "LinearLeastSquares", "3DVAR"]
index d76a9dbe3ef22495d7befae5733fa5aab51993a0..52e5ececeb373643d611f2d46680dcec1cddf555 100644 (file)
@@ -2,10 +2,29 @@ include $(top_srcdir)/adm_local/make_common_starter.am
 
 DATA_INST = \
            test000_Blue_AnalysisCode.py test000_Blue_AnalysisFile.py test000_Blue.py \
-           test017_3DVAR_par_fonction.py test017_3DVAR_function_script.py test017_3DVAR_init_data.py
+           test017_3DVAR_par_fonction.py test017_3DVAR_function_script.py test017_3DVAR_init_data.py \
+           test_aster_zzzz159a_background_error.py \
+           test_aster_zzzz159a_background.py \
+           test_aster_zzzz159a_observation_error.py \
+           test_aster_zzzz159a_observation.py \
+           test_aster_zzzz159a_functions.py \
+           test_aster_zzzz159a_aster_functions.py \
+           test_aster_zzzz159a_init_algorithm.py \
+           test_aster_zzzz159a_init_parameters.py \
+           test_aster_zzzz159a.py \
+           zzzz159a.3  zzzz159a.export.esclave  zzzz159a.mail
 
 testsdasalome_DATA = ${DATA_INST}
 
 EXTRA_DIST = test000_Blue_AnalysisCode.py test000_Blue_AnalysisFile.py.in test000_Blue.py \
-            test017_3DVAR_par_fonction.py.in test017_3DVAR_function_script.py test017_3DVAR_init_data.py
-
+            test017_3DVAR_par_fonction.py.in test017_3DVAR_function_script.py test017_3DVAR_init_data.py \
+            test_aster_zzzz159a_background_error.py \
+            test_aster_zzzz159a_background.py \
+            test_aster_zzzz159a_observation_error.py \
+            test_aster_zzzz159a_observation.py \
+            test_aster_zzzz159a_functions.py \
+            test_aster_zzzz159a_aster_functions.py \
+            test_aster_zzzz159a_init_algorithm.py \
+            test_aster_zzzz159a_init_parameters.py.in \
+            test_aster_zzzz159a.py.in \
+            zzzz159a.3  zzzz159a.export.esclave.in  zzzz159a.mail
diff --git a/src/tests/daSalome/test_aster_zzzz159a.py.in b/src/tests/daSalome/test_aster_zzzz159a.py.in
new file mode 100644 (file)
index 0000000..b02239a
--- /dev/null
@@ -0,0 +1,54 @@
+#-*-coding:iso-8859-1-*-
+study_config = {}
+study_config["Name"] = "test_aster_zzzz159a"
+study_config["Algorithm"] = "3DVAR"
+
+Init_config = {}
+Init_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_init_parameters.py"
+Init_config["Type"] = "Dict"
+Init_config["From"] = "Script"
+Init_config["Target"] = ["Algorithm"]
+study_config["Init"] = Init_config
+
+Algorithm_config = {}
+Algorithm_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_init_algorithm.py"
+Algorithm_config["Type"] = "Dict"
+Algorithm_config["From"] = "Script"
+study_config["Algorithm"] = Algorithm_config
+
+Background_config = {}
+Background_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_background.py"
+Background_config["Type"] = "Vector"
+Background_config["From"] = "Script"
+study_config["Background"] = Background_config
+
+BackgroundError_config = {}
+BackgroundError_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_background_error.py"
+BackgroundError_config["Type"] = "Matrix"
+BackgroundError_config["From"] = "Script"
+study_config["BackgroundError"] = BackgroundError_config
+
+Observation_config = {}
+Observation_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_observation.py"
+Observation_config["Type"] = "Vector"
+Observation_config["From"] = "Script"
+study_config["Observation"] = Observation_config
+
+ObservationError_config = {}
+ObservationError_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_observation_error.py"
+ObservationError_config["Type"] = "Matrix"
+ObservationError_config["From"] = "Script"
+study_config["ObservationError"] = ObservationError_config
+
+FunctionDict = {}
+FunctionDict["Function"] = ["Direct", "Tangent", "Adjoint"]
+FunctionDict["Script"] = {}
+FunctionDict["Script"]["Direct"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_functions.py"
+FunctionDict["Script"]["Tangent"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_functions.py"
+FunctionDict["Script"]["Adjoint"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_functions.py"
+ObservationOperator_config = {}
+ObservationOperator_config["Data"] = FunctionDict
+ObservationOperator_config["Type"] = "Function"
+ObservationOperator_config["From"] = "Dict"
+study_config["ObservationOperator"] = ObservationOperator_config
+
diff --git a/src/tests/daSalome/test_aster_zzzz159a_aster_functions.py b/src/tests/daSalome/test_aster_zzzz159a_aster_functions.py
new file mode 100644 (file)
index 0000000..817aae9
--- /dev/null
@@ -0,0 +1,525 @@
+#!/usr/bin/python
+# -*- coding: iso-8859-1 -*-
+
+import os, sys, shutil, tempfile, glob
+from math import log10
+
+# Variables globales
+debug=False
+ASTER_ROOT   = ''
+SOURCES_ROOT = ''
+export = None
+calcul = None
+parametres = None
+python_version = ''
+
+#===============================================================================
+def UTMESS(code='I', txt=''):
+   print txt
+   if code=='F': sys.exit()
+
+#===============================================================================
+def get_tables(tables_calc,tmp_repe_table,prof):
+   """ Recupere les resultats Aster (Table Aster -> Numeric Python)
+   """
+   import Numeric
+   assert (tables_calc is not None)
+   assert (tmp_repe_table is not None)
+
+   # Import du module lire_table
+   if os.environ.has_key('ASTER_ROOT'):
+      version = prof['version'][0]
+      bibpyt = os.path.join(os.environ['ASTER_ROOT'], version, 'bibpyt')
+      sys.path.append(bibpyt)
+      for mdl in glob.glob(os.path.join(bibpyt, '*')):
+        sys.path.append(os.path.join(os.environ['ASTER_ROOT'], version, 'bibpyt', mdl))
+   try:
+      from lire_table_ops import lecture_table
+   except:
+      UTMESS('F', "Impossible d'importer le module lire_table!")
+
+   reponses = tables_calc
+   Lrep=[]
+   _TB = [None]*len(reponses)
+   for i in range(len(reponses)):
+      _fic_table = tmp_repe_table + os.sep + "fort."+str(int(100+i))
+
+      try:
+        file=open(_fic_table,'r')
+        texte=file.read()
+        file.close()
+      except Exception, err:
+        ier=1
+        message = "Erreur 1!\n" + str(err)
+        UTMESS('F', message)
+
+      try:
+        table_lue = lecture_table(texte, 1, ' ')
+        list_para = table_lue.para
+        tab_lue   = table_lue.values()
+      except Exception, err:
+        ier=1
+        message = "Erreur 2!\n" + str(err)
+      else:
+        ier=0
+
+      if ier!=0 : UTMESS('F', message)
+
+      try:
+         nb_val = len(tab_lue[ list_para[0] ])
+         F = Numeric.zeros((nb_val,2), Numeric.Float)
+         for k in range(nb_val):
+           F[k][0] = tab_lue[ str(reponses[i][1]) ][k]
+           F[k][1] = tab_lue[ str(reponses[i][2]) ][k]
+         Lrep.append(F)
+      except Exception, err:
+         message = "Erreur 3!\n" + str(err)
+         UTMESS('F', message)
+   resu_calc = Lrep
+   from N_Parameters import debug
+   if debug: print 'resu_calc:', resu_calc
+
+   return resu_calc
+#===============================================================================
+
+
+#===============================================================================
+def Calcul_Aster_Ponctuel( X0 = None ):
+    #
+    import numpy
+    if type(X0) is type(numpy.matrix([])):
+        X0 = X0.A1.tolist()
+    else:
+        X0 = list(X0)
+    # ----------------------------------------------------------------------------
+    # Parametres
+    isFromYacs = globals().get('ASTER_ROOT', None)  # execution via YACS ou en externe
+    if not isFromYacs:
+        from N_Parameters import ASTER_ROOT, debug, SOURCES_ROOT, DISPLAY
+        from N_Study_Parameters import export
+        from N_MR_Parameters import calcul, parametres
+    os.environ['ASTER_ROOT'] = ASTER_ROOT
+
+    # ----------------------------------------------------------------------------
+    # Repertoire contenant les resultats des calculs Aster (None = un rep temp est cree)
+    resudir = globals().get('resudir', None)
+
+    # ----------------------------------------------------------------------------
+    # Parametres remis en forme
+    list_params = [x[0] for x in parametres]
+    list_calc = calcul
+
+    # ----------------------------------------------------------------------------
+    # Procedure de calculs distribues
+    #
+    # Import des modules python d'ASTK
+    astk_serv_root = os.path.join(ASTER_ROOT, 'ASTK', 'ASTK_SERV')
+    sys.path.append(os.path.join(astk_serv_root, 'lib'))
+    sys.path.append(os.path.join(ASTER_ROOT, 'lib', python_version, 'site-packages'))
+    if debug:
+        print sys.path
+    try:
+      from asrun.run          import AsRunFactory
+      from asrun.profil       import ASTER_PROFIL
+      from asrun.common_func  import get_hostrc
+      from asrun.utils        import get_timeout
+      from asrun.parametric   import is_list_of_dict
+      from asrun.thread       import Dispatcher
+      from asrun.distrib      import DistribParametricTask
+    except Exception, e:
+      print e
+      UTMESS('F', "Impossible de determiner l'emplacement d'Aster ! Fixer le chemin avec la variable d'environnement ASTER_ROOT.")
+
+    # Import des modules supplementaires
+    sys.path.insert(0, SOURCES_ROOT)
+    sys.path.insert(0, os.path.join(SOURCES_ROOT, 'sources'))
+
+
+    # result directories
+    if resudir:
+       if not os.path.isdir(resudir):
+          try:    os.mkdir(resudir)
+          except: 
+             UTMESS('A', "Impossible de creer le repertoire : %s. On utilise un repertoire temporaire" % resudir)
+             resudir = None
+    if not resudir: resudir = tempfile.mkdtemp(prefix='tmp_macr_recal_')
+    flashdir = os.path.join(resudir,'flash')
+    UTMESS('I', "\n       ASTER Exécution simple\n       Répertoire temporaire de résultats : %s" % resudir)
+
+    sys.argv = ['']
+
+    run = AsRunFactory()
+
+    prof = ASTER_PROFIL(filename=export)
+    #prof = init_profil_from(run, prof, keep_surch=True)
+    prof.Set('R', {
+       'type' : 'repe', 'isrep' : True, 'ul' : 0, 'compr' : False,
+       'path' : '/tmp/test_param' })
+
+    if debug: print prof
+    prof.WriteExportTo( os.path.join(resudir, 'master.export') )
+
+    # get hostrc object
+    hostrc = get_hostrc(run, prof)
+
+    # timeout before rejected a job
+    timeout = get_timeout(prof)
+
+
+    # list of parameters
+    list_val = []
+
+    # Dictionnaire des parametres du point courant
+    dic = dict( zip( list_params, X0 ) )
+    list_val.append( dic )
+
+    assert is_list_of_dict(list_val)
+    nbval = len(list_val)
+
+
+    # Ajout des impressions de tables a la fin du .comm
+    t = []
+    reponses = list_calc
+    for i in range(len(reponses)):
+        _ul = str(int(100+i))
+        num_ul = '99'
+
+        try:    os.remove( tmp_macr_recal+os.sep+"REPE_TABLE"+os.sep+"fort."+_ul )
+        except: pass
+
+        t.append("\n# Recuperation de la table : " + str(reponses[i][0]) + "\n")
+        t.append("DEFI_FICHIER(UNITE=" + num_ul + ", FICHIER='" + os.path.join('.', 'REPE_OUT', 'fort.'+_ul) + "',);\n" )
+        t.append("IMPR_TABLE(TABLE="+str(reponses[i][0])+", FORMAT='ASTER', UNITE="+num_ul+", INFO=1, FORMAT_R='E30.20',);\n")
+        t.append("DEFI_FICHIER(ACTION='LIBERER', UNITE="+num_ul+",);\n")
+
+
+    # number of threads to follow execution
+    numthread = 1
+
+    # ----- Execute calcutions in parallel using a Dispatcher object
+    # elementary task...
+    task = DistribParametricTask(run=run, prof=prof, # IN
+                      hostrc=hostrc,
+                      nbmaxitem=0, timeout=timeout,
+                      resudir=resudir, flashdir=flashdir,
+                      keywords={'POST_CALCUL': '\n'.join(t)},
+                      info=1,
+                      nbnook=0, exec_result=[])            # OUT
+    # ... and dispatch task on 'list_tests'
+    etiq = 'calc_%%0%dd' % (int(log10(nbval)) + 1)
+    labels = [etiq % (i+1) for i in range(nbval)]
+    couples = zip(labels, list_val)
+    execution = Dispatcher(couples, task, numthread=numthread)
+
+    iret = 0
+    if task.nbnook > 0:
+        iret = 4
+    #run.Sortie(iret)
+
+    # Recuperation des tables calculees
+    seq_FX   = []
+    seq_FY   = []
+    seq_DIMS = []
+    lst_DIAG = []
+    lst_iter = []
+    i=0
+    for c in labels:
+        tbl = get_tables(tables_calc=list_calc, tmp_repe_table=os.path.join(resudir, c, 'REPE_OUT'), prof=prof)
+        FX = []
+        FY = []
+        ldims = []
+        for array in tbl:
+#           print 'AA1:', array
+#           print array[0]
+            FX.extend([ x[0] for x in array ])
+            FY.extend([ x[1] for x in array ])
+            ldims.append(len(array))
+
+        # Agregation des resultats
+        seq_FX.append(FX)
+        seq_FY.append(FY)
+        seq_DIMS.append(ldims)
+        lst_iter.append(i)
+        i+=1
+
+    # Liste des diagnostics
+    d_diag = {}
+    for result in task.exec_result:
+        label = result[0]
+        diag  = result[2]
+        d_diag[label] = diag
+    lst_DIAG = [ d_diag[label] for label in labels]
+
+    if debug:
+        print
+        print "list_calc =",list_calc
+        print "seq_FX    =",seq_FX
+        print "seq_FY    =",seq_FY
+        print "seq_DIMS  =",seq_DIMS
+        print "lst_DIAG  =",lst_DIAG
+        print "lst_iter  =",lst_iter
+        print
+
+    # ----------------------------------------------------------------------------
+    # Procedure d'assemblage du gradient
+
+    # Calcul maitre (point X0)
+    idx0 = lst_iter.index(0)   # index (les calculs arrivent-ils dans le desordre?)
+    FY_X0 = seq_FY[idx0]
+    H_de_X = FY_X0
+
+    # Arret si tous les jobs ne se sont pas deroules correctement
+    for diag in lst_DIAG:
+        if not diag[0:2] in ['OK', '<A']:
+            raise ValueError("Au moins un calcul ne s'est pas deroule normalement")
+
+    if debug:
+        print "\nH_de_X (calcul ponstuel) au point X0: \n%s" % str(H_de_X)
+
+    return H_de_X
+
+#===============================================================================
+def Calcul_Aster_Jacobienne( X0 = None ):
+    #
+    import numpy
+    if type(X0) is type(numpy.matrix([])):
+        X0 = X0.A1.tolist()
+    else:
+        X0 = list(X0)
+    # ----------------------------------------------------------------------------
+    FacteurdX = 1.e-4
+    dX = globals().get('dX', [ x*FacteurdX for x in X0 ])  # execution via YACS ou en externe
+    # dX = globals().get('dX', [ 0.1, 0.1, 0.001])  # execution via YACS ou en externe
+    # ----------------------------------------------------------------------------
+    # Parametres
+    isFromYacs = globals().get('ASTER_ROOT', None)  # execution via YACS ou en externe
+    if not isFromYacs:
+        from N_Parameters import ASTER_ROOT, debug, SOURCES_ROOT, DISPLAY
+        from N_Study_Parameters import export
+        from N_MR_Parameters import calcul, parametres
+    os.environ['ASTER_ROOT'] = ASTER_ROOT
+
+    # ----------------------------------------------------------------------------
+    # Repertoire contenant les resultats des calculs Aster (None = un rep temp est cree)
+    resudir = globals().get('resudir', None)
+
+    # ----------------------------------------------------------------------------
+    # Parametres remis en forme
+    list_params = [x[0] for x in parametres]
+    list_calc = calcul
+
+    # ----------------------------------------------------------------------------
+    # Procedure de calculs distribues
+    #
+    # Import des modules python d'ASTK
+    astk_serv_root = os.path.join(ASTER_ROOT, 'ASTK', 'ASTK_SERV')
+    sys.path.append(os.path.join(astk_serv_root, 'lib'))
+    sys.path.append(os.path.join(ASTER_ROOT, 'lib', python_version, 'site-packages'))
+    if debug:
+        print sys.path
+    try:
+      from asrun.run          import AsRunFactory
+      from asrun.profil       import ASTER_PROFIL
+      from asrun.common_func  import get_hostrc
+      from asrun.utils        import get_timeout
+      from asrun.parametric   import is_list_of_dict
+      from asrun.thread       import Dispatcher
+      from asrun.distrib      import DistribParametricTask
+    except Exception, e:
+      print e
+      UTMESS('F', "Impossible de determiner l'emplacement d'Aster ! Fixer le chemin avec la variable d'environnement ASTER_ROOT.")
+
+    # Import des modules supplementaires
+    sys.path.insert(0, SOURCES_ROOT)
+    sys.path.insert(0, os.path.join(SOURCES_ROOT, 'sources'))
+
+
+    # result directories
+    if resudir:
+       if not os.path.isdir(resudir):
+          try:    os.mkdir(resudir)
+          except: 
+             UTMESS('A', "Impossible de creer le repertoire : %s. On utilise un repertoire temporaire" % resudir)
+             resudir = None
+    if not resudir: resudir = tempfile.mkdtemp(prefix='tmp_macr_recal_')
+    flashdir = os.path.join(resudir,'flash')
+    UTMESS('I', "\n       ASTER Exécutions multiples\n       Répertoire temporaire de résultats : %s" % resudir)
+
+    sys.argv = ['']
+
+    run = AsRunFactory()
+
+    prof = ASTER_PROFIL(filename=export)
+    #prof = init_profil_from(run, prof, keep_surch=True)
+    prof.Set('R', {
+       'type' : 'repe', 'isrep' : True, 'ul' : 0, 'compr' : False,
+       'path' : '/tmp/test_param' })
+
+    if debug: print prof
+    prof.WriteExportTo( os.path.join(resudir, 'master.export') )
+
+    # get hostrc object
+    hostrc = get_hostrc(run, prof)
+
+    # timeout before rejected a job
+    timeout = get_timeout(prof)
+
+
+    # list of parameters
+    list_val = []
+
+    # Dictionnaire des parametres du point courant
+    dic = dict( zip( list_params, X0 ) )
+    list_val.append( dic )
+
+    # Dictionnaires des parametres des calculs esclaves (perturbations des differences finies)
+    for n in range(1,len(dX)+1):
+        l = [0] * len(dX)
+        l[n-1] = dX[n-1]
+        X = [ X0[i] + l[i] for i in range(len(dX)) ]
+        dic = dict( zip( list_params, X ) )
+        list_val.append( dic )
+
+    assert is_list_of_dict(list_val)
+    nbval = len(list_val)
+
+
+    # Ajout des impressions de tables a la fin du .comm
+    t = []
+    reponses = list_calc
+    for i in range(len(reponses)):
+        _ul = str(int(100+i))
+        num_ul = '99'
+
+        try:    os.remove( tmp_macr_recal+os.sep+"REPE_TABLE"+os.sep+"fort."+_ul )
+        except: pass
+
+        t.append("\n# Recuperation de la table : " + str(reponses[i][0]) + "\n")
+        t.append("DEFI_FICHIER(UNITE=" + num_ul + ", FICHIER='" + os.path.join('.', 'REPE_OUT', 'fort.'+_ul) + "',);\n" )
+        t.append("IMPR_TABLE(TABLE="+str(reponses[i][0])+", FORMAT='ASTER', UNITE="+num_ul+", INFO=1, FORMAT_R='E30.20',);\n")
+        t.append("DEFI_FICHIER(ACTION='LIBERER', UNITE="+num_ul+",);\n")
+
+
+    # number of threads to follow execution
+    numthread = 1
+
+    # ----- Execute calcutions in parallel using a Dispatcher object
+    # elementary task...
+    task = DistribParametricTask(run=run, prof=prof, # IN
+                      hostrc=hostrc,
+                      nbmaxitem=0, timeout=timeout,
+                      resudir=resudir, flashdir=flashdir,
+                      keywords={'POST_CALCUL': '\n'.join(t)},
+                      info=1,
+                      nbnook=0, exec_result=[])            # OUT
+    # ... and dispatch task on 'list_tests'
+    etiq = 'calc_%%0%dd' % (int(log10(nbval)) + 1)
+    labels = [etiq % (i+1) for i in range(nbval)]
+    couples = zip(labels, list_val)
+    execution = Dispatcher(couples, task, numthread=numthread)
+
+    iret = 0
+    if task.nbnook > 0:
+        iret = 4
+    #run.Sortie(iret)
+
+    # Recuperation des tables calculees
+    seq_FX   = []
+    seq_FY   = []
+    seq_DIMS = []
+    lst_DIAG = []
+    lst_iter = []
+    i=0
+    for c in labels:
+        tbl = get_tables(tables_calc=list_calc, tmp_repe_table=os.path.join(resudir, c, 'REPE_OUT'), prof=prof)
+        FX = []
+        FY = []
+        ldims = []
+        for array in tbl:
+#           print 'AA1:', array
+#           print array[0]
+            FX.extend([ x[0] for x in array ])
+            FY.extend([ x[1] for x in array ])
+            ldims.append(len(array))
+
+        # Agregation des resultats
+        seq_FX.append(FX)
+        seq_FY.append(FY)
+        seq_DIMS.append(ldims)
+        lst_iter.append(i)
+        i+=1
+
+    # Liste des diagnostics
+    d_diag = {}
+    for result in task.exec_result:
+        label = result[0]
+        diag  = result[2]
+        d_diag[label] = diag
+    lst_DIAG = [ d_diag[label] for label in labels]
+
+    if debug:
+        print
+        print "list_calc =",list_calc
+        print "seq_FX    =",seq_FX
+        print "seq_FY    =",seq_FY
+        print "seq_DIMS  =",seq_DIMS
+        print "lst_DIAG  =",lst_DIAG
+        print "lst_iter  =",lst_iter
+        print "dX        =",dX
+        print
+
+    # ----------------------------------------------------------------------------
+    # Procedure d'assemblage du gradient
+
+    # Calcul maitre (point X0)
+    idx0 = lst_iter.index(0)   # index (les calculs arrivent-ils dans le desordre?)
+    FY_X0 = seq_FY[idx0]
+    H_de_X = FY_X0
+
+    # Arret si tous les jobs ne se sont pas deroules correctement
+    for diag in lst_DIAG:
+        if not diag[0:2] in ['OK', '<A']:
+            raise ValueError("Au moins un calcul ne s'est pas deroule normalement")
+
+    # Calcul du gradient (une liste de liste)
+    Gradient_de_H_en_X = []
+
+    for n in range(len(lst_iter))[1:]:
+        idx = lst_iter.index(n)
+        FY   = seq_FY[idx]
+        col = [ -(y-x)/dX[idx-1] for x, y in zip(FY, FY_X0) ]
+        Gradient_de_H_en_X.append(col)
+        if debug: print 'Calcul numero: %s - Diagnostic: %s' % (n, lst_DIAG[idx])
+
+    if debug:
+        print "\nCalcul H au point X0: \n%s" % str(H_de_X)
+        import pprint
+        print "\nGradient au point X0:"
+        pprint.pprint(Gradient_de_H_en_X)
+
+    return Gradient_de_H_en_X
+
+#===============================================================================
+def Calcul_Aster_Adjoint( (X0, dY) ):
+    #
+    if 0:
+        print
+        print "CALCUL ADJOINT"
+        print "X0 =",X0
+        print "dY =",dY
+    #
+    import numpy
+    #
+    Y0 = numpy.asmatrix(dY).flatten().T
+    #
+    Delta_HX = Calcul_Aster_Jacobienne( X0 )
+    Delta_HX = numpy.matrix( Delta_HX )
+    #
+    HtY = numpy.dot(Delta_HX, Y0)
+    #
+    if 0:
+        print "dHX =",Delta_HX
+        print "HtY =",HtY
+        print
+    #
+    return HtY.A1
diff --git a/src/tests/daSalome/test_aster_zzzz159a_background.py b/src/tests/daSalome/test_aster_zzzz159a_background.py
new file mode 100644 (file)
index 0000000..40b0449
--- /dev/null
@@ -0,0 +1,13 @@
+debug = init_data["debug"]
+parametres = init_data["parametres"]
+
+xb = []
+Bornes = []
+for parametre in parametres:
+    xb.append( parametre[1] )
+if debug:
+    print
+    print "Ebauche = ",xb
+    print
+
+Background = xb
diff --git a/src/tests/daSalome/test_aster_zzzz159a_background_error.py b/src/tests/daSalome/test_aster_zzzz159a_background_error.py
new file mode 100644 (file)
index 0000000..98ced54
--- /dev/null
@@ -0,0 +1,15 @@
+parametres = init_data["parametres"]
+
+xb = []
+for parametre in parametres:
+    xb.append( parametre[1] )
+
+B  = numpy.matrix(numpy.core.identity(len(xb)))
+alpha  = 1.e14
+B[0,0] = alpha * 100
+B[1,1] = alpha * 10
+B[2,2] = alpha * 1
+dimensionXb = len( Xb )
+B = numpy.matrix( B, numpy.float ).reshape((dimensionXb,dimensionXb))
+
+BackgroundError = B
diff --git a/src/tests/daSalome/test_aster_zzzz159a_functions.py b/src/tests/daSalome/test_aster_zzzz159a_functions.py
new file mode 100644 (file)
index 0000000..f1e1e64
--- /dev/null
@@ -0,0 +1,26 @@
+import numpy
+import pickle
+import test_aster_zzzz159a_aster_functions as Code_Aster
+
+# Configuration du module
+Code_Aster.debug = init_data["debug"]
+Code_Aster.ASTER_ROOT = init_data["ASTER_ROOT"]
+Code_Aster.SOURCES_ROOT = init_data['SOURCES_ROOT']
+Code_Aster.export = init_data["export"]
+Code_Aster.calcul = init_data["calcul"]
+Code_Aster.parametres = init_data["parametres"]
+Code_Aster.python_version = init_data["python_version"]
+
+print computation["method"]
+
+if computation["method"] == "Direct":
+  result = Code_Aster.Calcul_Aster_Ponctuel(computation["data"])
+
+if computation["method"] == "Tangent":
+  result = Code_Aster.Calcul_Aster_Ponctuel(computation["data"])
+
+if computation["method"] == "Adjoint":
+  result = Code_Aster.Calcul_Aster_Adjoint(computation["data"])
+
+print "Computation end"
+
diff --git a/src/tests/daSalome/test_aster_zzzz159a_init_algorithm.py b/src/tests/daSalome/test_aster_zzzz159a_init_algorithm.py
new file mode 100644 (file)
index 0000000..a72431a
--- /dev/null
@@ -0,0 +1,15 @@
+debug = init_data["debug"]
+parametres = init_data["parametres"]
+
+Bornes = []
+for parametre in parametres:
+    Bornes.append(parametre[2:4])
+
+if debug:
+    print
+    print "Bornes  = ",Bornes
+    print
+
+Algorithm = { "Minimizer"           : "TNC",
+              "Bounds"              : Bornes,
+            }
diff --git a/src/tests/daSalome/test_aster_zzzz159a_init_parameters.py.in b/src/tests/daSalome/test_aster_zzzz159a_init_parameters.py.in
new file mode 100644 (file)
index 0000000..e7ccbb9
--- /dev/null
@@ -0,0 +1,68 @@
+#!/usr/bin/python
+# -*- coding: iso-8859-1 -*-
+
+import os
+
+# Ce script contient les information nécessaires à l'exécution
+# de l'étude
+
+init_data = {}
+
+# Variables de base
+init_data['ASTER_ROOT'] = os.environ['ASTER_ROOT']
+init_data['debug'] = False
+init_data['python_version'] = "python@PYTHON_VERSION@"
+
+# Partie contenant les parametres de l'étude
+export=os.environ["ADAO_ROOT_DIR"] + '/tests/daSalome/zzzz159a.export.esclave'
+
+import Numeric
+parametres =[['YOUN__',100000.,50000.,500000.],['DSDE__',1000.,500.,10000.],['SIGY__',30.,5.,500.]]
+calcul = [['REPONSE1','INST','SIYY'],['REPONSE2','INST','V1']]
+experience=[     Numeric.array([[0.00000E+00  , 0.00000E+00 ],
+                              [5.00000E-02  , 5.00000E+01 ],
+                              [1.00000E-01  , 1.00000E+02 ],
+                              [1.50000E-01  , 1.50000E+02 ],
+                              [2.00000E-01  , 2.00000E+02 ],
+                              [2.50000E-01  , 2.00500E+02 ],
+                              [3.00000E-01  , 2.01000E+02 ],
+                              [3.50000E-01  , 2.01500E+02 ],
+                              [4.00000E-01  , 2.02000E+02 ],
+                              [4.50000E-01  , 2.02500E+02 ],
+                              [5.00000E-01  , 2.03000E+02 ],
+                              [5.50000E-01  , 2.03500E+02 ],
+                              [6.00000E-01  , 2.04000E+02 ],
+                              [6.50000E-01  , 2.04500E+02 ],
+                              [7.00000E-01  , 2.05000E+02 ],
+                              [7.50000E-01  , 2.05500E+02 ],
+                              [8.00000E-01  , 2.06000E+02 ],
+                              [8.50000E-01  , 2.06500E+02 ],
+                              [9.00000E-01  , 2.07000E+02 ],
+                              [9.50000E-01  , 2.07500E+02 ],
+                              [1.00000E+00  , 2.08000E+02 ]]),
+                 Numeric.array([[0.00000E+00  , 0.00000E+00 ],
+                              [5.00000E-02  , 0.00000E+00 ],
+                              [1.00000E-01  , 0.00000E+00 ],
+                              [1.50000E-01  , 0.00000E+00 ],
+                              [2.00000E-01  , 0.00000E+00 ],
+                              [2.50000E-01  , 2.47500E-04 ],
+                              [3.00000E-01  , 4.95000E-04 ],
+                              [3.50000E-01  , 7.42500E-04 ],
+                              [4.00000E-01  , 9.90000E-04 ],
+                              [4.50000E-01  , 1.23750E-03 ],
+                              [5.00000E-01  , 1.48500E-03 ],
+                              [5.50000E-01  , 1.73250E-03 ],
+                              [6.00000E-01  , 1.98000E-03 ],
+                              [6.50000E-01  , 2.22750E-03 ],
+                              [7.00000E-01  , 2.47500E-03 ],
+                              [7.50000E-01  , 2.72250E-03 ],
+                              [8.00000E-01  , 2.97000E-03 ],
+                              [8.50000E-01  , 3.21750E-03 ],
+                              [9.00000E-01  , 3.46500E-03 ],
+                              [9.50000E-01  , 3.71250E-03 ],
+                              [1.00000E+00  , 3.96000E-03 ]]) ]
+
+init_data['parametres'] = parametres
+init_data['calcul'] = calcul
+init_data['experience'] = experience
+
diff --git a/src/tests/daSalome/test_aster_zzzz159a_observation.py b/src/tests/daSalome/test_aster_zzzz159a_observation.py
new file mode 100644 (file)
index 0000000..a3b5a49
--- /dev/null
@@ -0,0 +1,16 @@
+debug = init_data["debug"]
+experience = init_data["experience"]
+
+nbmesures = 11 # De 0 à 1 par pas de 0.1
+instants = numpy.array([0.1*i for i in range(nbmesures)])
+yo = []
+for reponse in experience:
+    for t,v in list(reponse):
+        if min(abs(t - instants)) < 1.e-8:
+            yo.append(v)
+            # print t,'===>',v
+if debug:
+    print "Observations = ",yo
+    print
+
+Observation = yo
diff --git a/src/tests/daSalome/test_aster_zzzz159a_observation_error.py b/src/tests/daSalome/test_aster_zzzz159a_observation_error.py
new file mode 100644 (file)
index 0000000..deaae3a
--- /dev/null
@@ -0,0 +1,12 @@
+experience = init_data["experience"]
+nbmesures = 11 # De 0 à 1 par pas de 0.1
+instants = numpy.array([0.1*i for i in range(nbmesures)])
+yo = []
+for reponse in experience:
+    for t,v in list(reponse):
+        if min(abs(t - instants)) < 1.e-8:
+            yo.append(v)
+
+R  = numpy.matrix(numpy.core.identity(len(yo)))
+dimensionYo = len( Yo )
+R = numpy.matrix( R, numpy.float ).reshape((dimensionYo,dimensionYo))
diff --git a/src/tests/daSalome/zzzz159a.3 b/src/tests/daSalome/zzzz159a.3
new file mode 100644 (file)
index 0000000..d591cf1
--- /dev/null
@@ -0,0 +1,83 @@
+DEBUT();
+
+DSDE__ = 200.;
+
+YOUN__ = 8.E4;
+
+SIGY__ = 1.;
+
+MA=LIRE_MAILLAGE();
+
+MA=DEFI_GROUP(reuse =MA,
+              MAILLAGE=MA,
+              CREA_GROUP_NO=_F(TOUT_GROUP_MA='OUI',),);
+
+
+ACIER=DEFI_MATERIAU(ECRO_LINE=_F(D_SIGM_EPSI=DSDE__,
+                                 SY=SIGY__,),
+                    ELAS=_F(NU=0.3,
+                            E=YOUN__,),);
+
+CHMAT=AFFE_MATERIAU(AFFE=_F(MATER=ACIER,
+                            TOUT='OUI',),
+                    MAILLAGE=MA,);
+
+MO=AFFE_MODELE(AFFE=_F(TOUT='OUI',
+                       PHENOMENE='MECANIQUE',
+                       MODELISATION='AXIS',),
+               MAILLAGE=MA,);
+
+TRACTION=AFFE_CHAR_MECA(DDL_IMPO=(_F(DY=5.E-3,
+                                     GROUP_NO='CD',),
+                                  _F(DY=0.0,
+                                     GROUP_NO='AB',),),
+                        MODELE=MO,);
+
+
+RAMPE=DEFI_FONCTION(NOM_PARA='INST',
+                    VALE=(0.0,0.0,1.0,1.0),);
+
+INSTANTS=DEFI_LIST_REEL(INTERVALLE=_F(JUSQU_A=1.0,
+                                      NOMBRE=10,),
+                        DEBUT=0.0,);
+
+EVOL=STAT_NON_LINE(CHAM_MATER=CHMAT,
+                   MODELE=MO,
+                   ARCHIVAGE=_F(LIST_INST=INSTANTS,
+                                ARCH_ETAT_INIT='OUI',),
+                   CONVERGENCE=_F(ITER_GLOB_MAXI=10,
+                                  RESI_GLOB_RELA=1.E-05,),
+                   COMP_INCR=_F(RELATION='VMIS_ISOT_LINE',),
+                   INCREMENT=_F(LIST_INST=INSTANTS,
+#                                SUBD_METHODE='UNIFORME',
+#                                SUBD_PAS=4,
+#                                SUBD_COEF_PAS_1=1.0,
+#                                SUBD_PAS_MINI=1.E-05,
+                                ),
+                   NEWTON=_F(REAC_ITER=1,
+                             REAC_INCR=1,),
+                   EXCIT=_F(CHARGE=TRACTION,
+                            FONC_MULT=RAMPE,),);
+
+EVOL=CALC_ELEM(reuse =EVOL,
+               RESULTAT=EVOL,
+               CHAM_MATER=CHMAT,
+               MODELE=MO,
+               OPTION=('SIEF_ELNO_ELGA','VARI_ELNO_ELGA'),);
+               
+REPONSE1=POST_RELEVE_T(ACTION=_F(OPERATION='EXTRACTION',
+                        INTITULE='SIGYY',
+                        RESULTAT =EVOL,
+                        NOM_CHAM ='SIEF_ELNO_ELGA',
+                        NOM_CMP  = 'SIYY',
+                        GROUP_NO = 'A',),);
+                        
+REPONSE2=POST_RELEVE_T(ACTION=_F(OPERATION='EXTRACTION',
+                        INTITULE='V1',
+                        RESULTAT =EVOL,
+                        NOM_CHAM ='VARI_ELNO_ELGA',
+                        NOM_CMP  = 'V1',
+                        GROUP_NO = 'A',),);
+                        
+
+FIN();
diff --git a/src/tests/daSalome/zzzz159a.export.esclave.in b/src/tests/daSalome/zzzz159a.export.esclave.in
new file mode 100644 (file)
index 0000000..5db5b97
--- /dev/null
@@ -0,0 +1,14 @@
+P version STA10.1
+P debug nodebug
+P mode interactif
+P nomjob zzzz159a
+P origine ASTK 1.8.0
+A memjeveux 16.0
+A tpmax 300
+P tpsjob 5
+P xterm /usr/bin/xterm -sb -si -geometry 90x32 -display localhost:0
+F comm @prefix@/tests/daSalome/zzzz159a.3 D 1
+F mail @prefix@/tests/daSalome/zzzz159a.mail D 20
+F mess @prefix@/tests/daSalome/zzzz159a_esclave.mess R 6
+F resu @prefix@/tests/daSalome/zzzz159a_esclave.resu R 8
+P actions make_etude
diff --git a/src/tests/daSalome/zzzz159a.mail b/src/tests/daSalome/zzzz159a.mail
new file mode 100644 (file)
index 0000000..83696f9
--- /dev/null
@@ -0,0 +1,65 @@
+TITRE
+ %  GIBI FECIT
+ FINSF
+ %
+ COOR_2D
+ N1        0.00000000000000E+00  0.00000000000000E+00
+ N2        1.00000000000000E+00  0.00000000000000E+00
+ N3        1.00000000000000E+00  1.00000000000000E+00
+ N4        0.00000000000000E+00  1.00000000000000E+00
+ FINSF
+ %
+ QUAD4   
+  M1      N1       N2       N3       N4      
+ FINSF
+ %
+ SEG2    
+  M2      N4       N1      
+  M3      N1       N2      
+  M4      N2       N3      
+  M5      N3       N4      
+ FINSF
+ %
+ GROUP_NO
+ D        N4      
+ FINSF
+ %
+ GROUP_NO
+ C        N3      
+ FINSF
+ %
+ GROUP_NO
+ A        N1      
+ FINSF
+ %
+ GROUP_NO
+ B        N2      
+ FINSF
+ %
+ GROUP_MA
+   AB      
+ M3      
+ FINSF
+ %
+ GROUP_MA
+   BC      
+ M4      
+ FINSF
+ %
+ GROUP_MA
+   CD      
+ M5      
+ FINSF
+ %
+ GROUP_MA
+   DA      
+ M2      
+ FINSF
+ %
+ GROUP_MA
+   MA      
+ M1      
+ M2       M3       M4       M5      
+ FINSF
+ %
+ FIN