From c005ba5fe96d5388afd02028b893f605c89c2c52 Mon Sep 17 00:00:00 2001 From: LUCIE BERTHON Date: Thu, 6 Sep 2018 11:53:00 +0200 Subject: [PATCH] Insertion de bloc a la creation d'un nouveau fichier --- InterfaceQT4/gereIcones.py | 4 +- MapIdentification/cata_map.py | 72 ------------------- MapIdentification/cata_map_cl0d.py | 58 ++++++++------- MapIdentification/cata_map_cl0d_exp.py | 17 +++-- MapIdentification/cata_map_cl0d_param.py | 37 ++++++---- .../mesScripts_MAPIDENTIFICATION.py | 44 ++++++++++-- 6 files changed, 105 insertions(+), 127 deletions(-) delete mode 100644 MapIdentification/cata_map.py diff --git a/InterfaceQT4/gereIcones.py b/InterfaceQT4/gereIcones.py index 4c278f36..82274d97 100644 --- a/InterfaceQT4/gereIcones.py +++ b/InterfaceQT4/gereIcones.py @@ -234,7 +234,9 @@ class ContientIcones(object): from .monViewTexte import ViewText try : if sys.platform[0:5]=="linux" : - cmd="xdg-open "+ str(fichier) + #cmd="xdg-open "+ str(fichier) + #changer pour marcher dans l'EDC + cmd="gedit "+ str(fichier) os.system(cmd) else : os.startfile(str(fichier)) diff --git a/MapIdentification/cata_map.py b/MapIdentification/cata_map.py deleted file mode 100644 index 423f081c..00000000 --- a/MapIdentification/cata_map.py +++ /dev/null @@ -1,72 +0,0 @@ -# Copyright (C) 2008-2018 EDF R&D -# -# This file is part of SALOME ADAO module -# -# 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. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -import os, re -import Accas -from Accas import * - -JdC = JDC_CATA ( - code = 'MapIdentification', - ) -VERSION_CATALOGUE='V_0' - - -Experiences = PROC(nom = 'experiences', - - description = SIMP(statut='o', typ='TXM', defaut=''), - experience = FACT(statut='o', max = "**", - experience_Name = SIMP (statut='o', typ='TXM'), - source = SIMP(statut='o', typ='TXM', into=['File','Dico','Value']), - b_source_file = BLOC(condition="source == 'File'", - exp_file = SIMP(statut = "o", typ = 'Fichier'), - ), - b_source_valeur = BLOC(condition="source == 'Value'", - exp_value = SIMP(statut = "o", typ = 'R'), - ), - b_source_dico = BLOC(condition="source == 'Dico'", - exp_dico = SIMP(statut = "o", typ = 'TXM'), - ), - Associated_simulation_step_number = SIMP(statut='o', typ='I', val_min=1), - dependancy = FACT( statut='o', - type_dependancy= SIMP(statut='o', - typ='TXM', into=['temperature','moisture','irradiation']), - source = SIMP(statut='o', typ='TXM', into=['File','Dico','Value']), - b_source_file = BLOC(condition="source == 'File'", - exp_file = SIMP(statut = "o", typ = 'Fichier'),), - b_source_valeur = BLOC(condition="source == 'Value'", - exp_value = SIMP(statut = "o", typ = 'R'),), - b_source_dico = BLOC(condition="source == 'Dico'", - exp_dico = SIMP(statut = "o", typ = 'TXM'),), - ), - ), - dimensions= FACT( statut = 'f', - diameter = SIMP(statut='o', typ='R', val_min = 0), - thickness = SIMP(statut='o', typ='R', val_min = 0), - number_elements = SIMP(statut='o', typ='I', val_min = 0), - ), - type_experience = SIMP(statut='o', typ='TXM', - into=['tension','creep','relaxation','cyclic','cyclic_stab','tube']), -) - - -TEXTE_NEW_JDC = 'Experiences()' - - - - diff --git a/MapIdentification/cata_map_cl0d.py b/MapIdentification/cata_map_cl0d.py index 86c714de..35f78a5b 100644 --- a/MapIdentification/cata_map_cl0d.py +++ b/MapIdentification/cata_map_cl0d.py @@ -22,24 +22,17 @@ import Accas from Accas import * from datetime import datetime from mapcore import getVersion -from prefs_MapIdentification import catalogues_param, catalogues_exp +from cata_map_cl0d_param import F_Parameters +from cata_map_cl0d_exp import F_Experiences + JdC = JDC_CATA ( code = 'MAP_c_solver_constitutive_law_0d', ) VERSION_CATALOGUE='2018.1.beta' -def openNewXmlExp(monMC): - - monMC.jdc.appli.appliEficas.maConfiguration.catalogues = catalogues_exp - monMC.jdc.appli.appliEficas.viewmanager.newEditor() - -def openNewXmlParam(monMC): - #monMC.jdc.appli.appliEficas.maConfiguration.catalogues = catalogues_param - monMC.jdc.appli.appliEficas.viewmanager.newEditor() - -def getName(monMC): - print 'to'*50 +def getLawName(monMC): + print "je chercher a recuperer le nom du fichier" print monMC.nom print monMC.val @@ -49,42 +42,43 @@ def getName(monMC): MAP_input_file = PROC(nom = 'MAP_input_file', -# ----------------------------------- + #----------------------------------- MAP_Version = SIMP(statut='o', typ='TXM', defaut=getVersion()), -# ----------------------------------- + #----------------------------------- output_directory = SIMP(statut='f', typ='Repertoire', defaut=os.path.join( os.path.dirname(os.getcwd()), datetime.now().strftime("%Y%m%d-%H%M")), ), -# ----------------------------------- + #----------------------------------- constitutive_law_formulation = SIMP(statut='f', typ='TXM'), -# ----------------------------------- + #----------------------------------- constitutive_law_parameters_status = SIMP(statut='o', typ='TXM', into=['Existing', 'New'], #defaut='New' ), -# ----------------------------------- + #----------------------------------- b_constitutive_law_parameters_existing = BLOC( condition="constitutive_law_parameters_status == 'Existing'", constitutive_law_parameters = SIMP( statut = "o", typ = ('Fichier', 'XML Files (*.xml);;All Files (*)'), - siValide=getName, + siValide=getLawName, ) ), -# ----------------------------------- + #----------------------------------- b_constitutive_law_parameters_new = BLOC( condition="constitutive_law_parameters_status == 'New'", constitutive_law_parameters = SIMP( statut = "o", typ = ('FichierNoAbs', 'XML Files (*.xml);;All Files (*)'), - siValide=openNewXmlParam, - ) + ), + #----------------------------------- + Parameters = F_Parameters(statut='o') ), -# ----------------------------------- + #----------------------------------- user_defined_mfront_file_directory = SIMP(statut='f', typ='Repertoire', defaut=os.path.join( @@ -92,13 +86,12 @@ MAP_input_file = PROC(nom = 'MAP_input_file', "share/mfront/tests", "behaviours"), ), -# ----------------------------------- + #----------------------------------- exp_filename_list_status = SIMP(statut='o', typ='TXM', into=['Existing', 'New'], - #defaut='New' ), -# ----------------------------------- + #----------------------------------- b_exp_filename_list_existing = BLOC( condition="exp_filename_list_status == 'Existing'", exp_filename_list = SIMP( @@ -106,15 +99,20 @@ MAP_input_file = PROC(nom = 'MAP_input_file', typ = ('Fichier', 'XML Files (*.xml);;All Files (*)'), ) ), -# ----------------------------------- + #----------------------------------- b_exp_filename_list_new = BLOC( condition="exp_filename_list_status == 'New'", exp_filename_list = SIMP( statut = "o", - typ = ('FichierNoAbs', 'XML Files (*.xml);;All Files (*)'), - siValide=openNewXmlExp, - ) - ) + typ = ('FichierNoAbs', 'XML Files (*.xml);;All Files (*)') + ), + #----------------------------------- + Experiences = F_Experiences(statut='o') + ), + #----------------------------------- + mtest_options = SIMP(statut = "f", typ = ('Fichier')), + #----------------------------------- + interface = SIMP(statut='f', typ='TXM'), ) diff --git a/MapIdentification/cata_map_cl0d_exp.py b/MapIdentification/cata_map_cl0d_exp.py index a0e94680..529c8550 100644 --- a/MapIdentification/cata_map_cl0d_exp.py +++ b/MapIdentification/cata_map_cl0d_exp.py @@ -51,11 +51,8 @@ class Tuple: # Catalog entry for the experiences plan # ======================================================================= -Experiences = PROC(nom='Experiences', - - #----------------------------------- - MAP_Version = SIMP(statut='o', typ='TXM', defaut=getVersion()), - #----------------------------------- +def F_Experiences(statut) : return FACT( + statut=statut, Description = SIMP(statut='f', typ='TXM'), #----------------------------------- Experience = FACT(statut='o', max="**", @@ -162,4 +159,14 @@ Experiences = PROC(nom='Experiences', ) ) + + +Experiences = PROC(nom='Experiences', + + #----------------------------------- + MAP_Version = SIMP(statut='o', typ='TXM', defaut=getVersion()), + #----------------------------------- + Experiences = F_Experiences(statut='o') +) + TEXTE_NEW_JDC = 'Experiences()' diff --git a/MapIdentification/cata_map_cl0d_param.py b/MapIdentification/cata_map_cl0d_param.py index f52b365b..8dfa63cf 100644 --- a/MapIdentification/cata_map_cl0d_param.py +++ b/MapIdentification/cata_map_cl0d_param.py @@ -31,31 +31,38 @@ VERSION_CATALOGUE='2018.1.beta' # Catalog entry for the list of material parameters # ======================================================================= -Parameters_list = PROC(nom = 'List of material parameters', - -# ----------------------------------- - MAP_Version = SIMP(statut='o', typ='TXM', defaut=getVersion()), -# ----------------------------------- - Description = SIMP(statut='f', typ='TXM', defaut=''), -# ----------------------------------- - Law = SIMP(statut='o', typ='TXM', defaut=''), -# ----------------------------------- +def F_Parameters(statut) : return FACT( + statut=statut, + #----------------------------------- + Description = SIMP(statut='f', typ='TXM'), + #----------------------------------- + Law = SIMP(statut='o', typ='TXM'), + #----------------------------------- Parameter = FACT(statut='o', max="**", -# ----------------------------------- + #----------------------------------- Name = SIMP (statut='o', typ='TXM'), -# ----------------------------------- + #----------------------------------- Type = SIMP(statut='o', typ='TXM', into=["MaterialProperty", "ExternalStateVariable", "Parameter", "comm"]), -# ----------------------------------- + #----------------------------------- Value = SIMP(statut='o', typ='R'), -# ----------------------------------- + #----------------------------------- Adjustement = SIMP(statut='o', typ=bool), # TODO: case a cocher ou decocher -# ----------------------------------- + #----------------------------------- Lower_bound = SIMP(statut='f', typ='R', val_min=0), #TODO: rule: inf < sup -# ----------------------------------- + #----------------------------------- Upper_bound = SIMP(statut='f', typ='R', val_min=0), #TODO: rule: inf < sup ), + ) + + +Parameters_list = PROC(nom = 'List of material parameters', + + #----------------------------------- + MAP_Version = SIMP(statut='o', typ='TXM', defaut=getVersion()), + #----------------------------------- + parameters = F_Parameters(statut='o') ) TEXTE_NEW_JDC = 'Parameters_list()' diff --git a/MapIdentification/mesScripts_MAPIDENTIFICATION.py b/MapIdentification/mesScripts_MAPIDENTIFICATION.py index 029bee72..a1bbdd6a 100644 --- a/MapIdentification/mesScripts_MAPIDENTIFICATION.py +++ b/MapIdentification/mesScripts_MAPIDENTIFICATION.py @@ -1,8 +1,44 @@ -def run(listeParam): +import re +import os + +def comm2MAPinput(input_filename): + # Saving my input file by converting comm file into ini + with open(input_filename) as input_file: + lines = input_file.readlines() + + string = "[C_solver_constitutive_law0d]\n" + keys =["output_directory", + "constitutive_law_formulation", + "constitutive_law_parameters", + "user_defined_mfront_file_directory", + "exp_filename_list", + "mtest_options", + "interface"] + for line in lines: + for key in keys: + if key + "=" in line: + string += key + "=" + line.split("'")[1] + "\n" + + output_filename = os.path.splitext(input_filename)[0] + ".input" + with open(output_filename, "w") as new_file: + new_file.write(string) + print ('je convertis le fichier comm en input de MAP') + + return output_filename + +def run(editor): print ('je rentre dans run') - editor=listeParam[0] - print (editor) - print (dir(editor)) + command_file = "/home/C41270/MAPinput_test.comm" # TODO: nom en dur + + command_file = comm2MAPinput(command_file) + os.system("map -r sappli run -n C_solver_constitutive_law0d -i " + command_file) + print "calcul fini, youpi !" + #+def run(listeParam): + #+ print ('je rentre dans run') + #+ editor=listeParam[0] + #+ print (editor) + #+ print (dir(editor)) + # le dictionnaire des commandes a la structure suivante : # la clef est la commande qui va proposer l action -- 2.39.2