]> SALOME platform Git repositories - tools/eficas.git/commitdiff
Salome HOME
version qui fonctionne dans les grandes lignes
authorLUCIE BERTHON <C41270@dsp0887684.atlas.edf.fr>
Wed, 12 Sep 2018 09:24:24 +0000 (11:24 +0200)
committerLUCIE BERTHON <C41270@dsp0887684.atlas.edf.fr>
Wed, 12 Sep 2018 09:24:24 +0000 (11:24 +0200)
MapIdentification/cata_map_cl0d.py
MapIdentification/cata_map_cl0d_param.py
MapIdentification/mesScripts_MAPIDENTIFICATION.py

index f83e923a0e34229a50db7ac36e8d7216b03954e6..1c9dcf61978655ecd0a7eba391799815231bdead 100644 (file)
@@ -52,19 +52,20 @@ MAP_input_file = PROC(nom = 'MAP_input_file',
                                 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'],
             ),
         #-----------------------------------
         b_constitutive_law_parameters_existing = BLOC(
             condition="constitutive_law_parameters_status == 'Existing'",
+            #-----------------------------------
             constitutive_law_parameters_existing = SIMP(
                 statut = "o", 
                 typ = ('Fichier', 'XML Files (*.xml);;All Files (*)'),
-                siValide=getLawName,
-                )
+                #siValide=getLawName,
+                ),
+            #-----------------------------------
+            constitutive_law_formulation = SIMP(statut='o', typ='TXM'),
             ),
         #-----------------------------------
         b_constitutive_law_parameters_new = BLOC(
index c30e197f99061e46afe0e60500650ac0765e3fc0..7241722d46aa3aa2d5d99266d18651b2c4ee72bc 100644 (file)
@@ -36,7 +36,7 @@ def F_Parameters(statut) : return FACT(
     #-----------------------------------
     Description = SIMP(statut='f', typ='TXM'),
     #-----------------------------------
-    Law = SIMP(statut='o', typ='TXM'),
+    constitutive_law_formulation = SIMP(statut='o', typ='TXM'),
     #-----------------------------------
     Parameter = FACT(statut='o', max="**",
             #-----------------------------------
index 18e26af380a5ac12bc510b73f90d7e549c378e2b..0fc3ac3c404f5e5e478a9078180ee0888dce9fde 100644 (file)
@@ -11,48 +11,56 @@ from mapy.mfront_common.readers.parameters_list_factory import (
     ParametersListWriter)
 
 MAP_KEYS =["output_directory",
-           "constitutive_law_formulation",
-           "constitutive_law_parameters",
            "user_defined_mfront_file_directory",
-           "exp_filename_list",
            "mtest_options",  "interface"]
 
-def comm2MAPinput(input_filename):
-    # Saving my input file by converting comm file into ini
-    print("on rentre dans comm2MAPinput pour " + input_filename)
-
-    with open(input_filename) as input_file:
-        data = input_file.read()
-
-    data = data.replace("=\n", "=").replace("=\t", "=")
-    data = re.sub(' +', ' ',data).split("\n")
-
-    string = "[c_solver_constitutive_law_0d]\n"
-    for line in data:
-        for key in MAP_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)
-
-    return output_filename
-
-
 def writeMAPinput(dictValeur, filename):
     """
     """
-    print("je rentre dans writeMAPinput")
+    #print("je rentre dans writeMAPinput")
+    #print (dictValeur)
+    #print("-"*80)
     config = RawConfigParser()
     config.add_section("c_solver_constitutive_law_0d")
+    if dictValeur["constitutive_law_parameters_status"]=="Existing":
+        config.set("c_solver_constitutive_law_0d",
+                   "constitutive_law_parameters",
+                   dictValeur["b_constitutive_law_parameters_existing"]\
+                       ["constitutive_law_parameters_existing"])
+        config.set("c_solver_constitutive_law_0d",
+                   "constitutive_law_formulation",
+                   dictValeur["b_constitutive_law_parameters_existing"]\
+                       ["constitutive_law_formulation"])
+    elif dictValeur["constitutive_law_parameters_status"]=="New":
+        config.set("c_solver_constitutive_law_0d",
+                   "constitutive_law_parameters",
+                   os.path.join(os.getenv('OLDPWD'),
+                                dictValeur["b_constitutive_law_parameters_new"]\
+                                    ["constitutive_law_parameters_new"]))
+        config.set("c_solver_constitutive_law_0d",
+                   "constitutive_law_formulation",
+                   dictValeur["b_constitutive_law_parameters_new"]\
+                       ["Parameters"]["constitutive_law_formulation"])
+    if dictValeur["exp_filename_list_status"]=="Existing":
+        config.set("c_solver_constitutive_law_0d",
+                   "exp_filename_list",
+                   dictValeur["b_exp_filename_list_existing"]\
+                       ["exp_filename_list_existing"])
+    elif dictValeur["exp_filename_list_status"]=="New":
+        config.set("c_solver_constitutive_law_0d",
+                   "exp_filename_list",
+                   os.path.join(os.getenv('OLDPWD'),
+                                dictValeur["b_exp_filename_list_new"]\
+                                    ["exp_filename_list_new"]))
+
     for key, value in dictValeur.iteritems():
         if key in MAP_KEYS:
             config.set("c_solver_constitutive_law_0d", key, value)
     filename = os.path.abspath(os.path.splitext(filename)[0] + ".input")
     with open(filename,'w') as f_out :
         config.write(f_out)
-    print("je sauvegarde les info dans " + filename)
+    print("je sauvegarde les inputs dans " + filename)
+    #os.system("head " + filename)
 
 
 def writeXMLmaterialparameters(param_dico, output_filename=None):
@@ -61,7 +69,7 @@ def writeXMLmaterialparameters(param_dico, output_filename=None):
     #print("je rentre dans writeXMLmaterialparameters")
 
     param_list = ParametersList()
-    param_list.add_law(param_dico["Parameters"]["Law"])
+    param_list.add_law(param_dico["Parameters"]["constitutive_law_formulation"])
     if param_dico["Parameters"].has_key("Description"):
         param_list.add_description(param_dico["Parameters"]["Description"])
     if param_dico.has_key("user_defined_mfront_file_directory"):
@@ -83,7 +91,8 @@ def writeXMLmaterialparameters(param_dico, output_filename=None):
     if output_filename is not None:
         output_filename = str(os.path.splitext(output_filename)[0] + ".xml")
     else:
-        output_filename = param_dico["constitutive_law_parameters_new"]
+        output_filename = os.path.join(
+            os.getenv('OLDPWD'), param_dico["constitutive_law_parameters_new"])
     writer = ParametersListWriter(output_filename)
     writer.write(param_list)
     print("je sauvegarde les parametres dans " + output_filename)
@@ -109,7 +118,7 @@ def writeXMLexperiences(exp_dico, output_filename=None):
         exp = ET.SubElement(root, "Experience")
         exp.set("name", iel["ExperienceName"])
         exp.set("type", iel["Type"])
-        obs = ET.SubElement(exp, "Experience")
+        obs = ET.SubElement(exp, "Observations")
         obs_source = ET.SubElement(obs, "Source")
         obs_source.set("type", iel["Observations"]["Source"])
         if obs_source.get("type") == "File":
@@ -147,7 +156,8 @@ def writeXMLexperiences(exp_dico, output_filename=None):
     if output_filename is not None:
         output_filename = str(os.path.splitext(output_filename)[0] + ".xml")
     else:
-        output_filename = exp_dico["exp_filename_list_new"]
+        output_filename = os.path.join(
+            os.getenv('OLDPWD'), exp_dico["exp_filename_list_new"])
 
     xmlstr = minidom.parseString(ET.tostring(root)).toprettyxml(indent="   ")
     #print xmlstr
@@ -171,15 +181,10 @@ def add_source(root, iel, section_name, var_name):
             source_elem.text = str(var["Variable"]["b_source_value"]["Value"])
 
 def run(listeParam):
-    print "on rentre dans run"
-    command_file=listeParam[0].fichier
-    command_file = comm2MAPinput(command_file)
-
     os.chdir(os.getenv('OLDPWD'))
-    command = "map -r sappli run -n c_solver_constitutive_law_0d -i " + command_file
-    print(command)
+    command = "map -r sappli run -n c_solver_constitutive_law_0d -i " 
+    command += os.path.splitext(listeParam[0].fichier)[0]+".input"
     os.system(command)
-    print "calcul fini, youpi !"
 
 # le dictionnaire des commandes a la structure suivante :
 # la clef est la commande qui va proposer l action