]> SALOME platform Git repositories - tools/eficas.git/commitdiff
Salome HOME
Ecriture des writerXML et INI globaux
authorLUCIE BERTHON <C41270@dsp0887684.atlas.edf.fr>
Fri, 7 Sep 2018 15:08:11 +0000 (17:08 +0200)
committerLUCIE BERTHON <C41270@dsp0887684.atlas.edf.fr>
Fri, 7 Sep 2018 15:08:11 +0000 (17:08 +0200)
MapIdentification/mesScripts_MAPIDENTIFICATION.py

index 86ed87772f01c750190a6c595e0f15f802bfe851..ac11603209e5b08855c22a8d29f439babbef4bb9 100644 (file)
@@ -10,16 +10,20 @@ MAP_KEYS =["output_directory",
            "constitutive_law_parameters",
            "user_defined_mfront_file_directory",
            "exp_filename_list",
-           "mtest_options",
-           "interface"]
+           "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:
-        lines = input_file.readlines()
+        data = input_file.read()
+
+    data = data.replace("=\n", "=").replace("=\t", "=")
+    data = re.sub(' +', ' ',data).split("\n")
 
-    string = "[c_solver_constitutive_law0d]\n"
-    for line in lines:
+    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"
@@ -36,10 +40,10 @@ def writeMAPinput(dictValeur, filename):
     """
     print("je rentre dans writeMAPinput")
     config = RawConfigParser()
-    config.add_section("c_solver_constitutive_law0d")
+    config.add_section("c_solver_constitutive_law_0d")
     for key, value in dictValeur.iteritems():
         if key in MAP_KEYS:
-            config.set("c_solver_constitutive_law0d", key, value)
+            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)
@@ -89,6 +93,7 @@ def writeXMLexperiences(exp_xml, filename):
             iel += 1
     writeXML(root, filename)
 
+
 def writeXML(xml_structure, filename):
     # Make the output easier to follow for human readers
     print("je rentre dans writeXML")
@@ -96,11 +101,12 @@ def writeXML(xml_structure, filename):
         filename = os.path.splitext(filename)[0] + ".xml"
 
     xmlstr = minidom.parseString(ET.tostring(xml_structure)).toprettyxml(indent="   ")
-    print xmlstr
+    #print xmlstr
     with open(filename,'w') as f_out :
         f_out.write(xmlstr)
     print("je sauvegarde les info dans " + filename)
 
+
 def add_param(param_xml, root, ind=""):
     param = ET.SubElement(root, "Parameter")
     param.set("name", param_xml["Name" + ind])
@@ -114,6 +120,7 @@ def add_param(param_xml, root, ind=""):
         value.set("sup", str(param_xml["Upper_bound" + ind]))
     return param_xml
 
+
 def add_exp(exp_xml, root, ind=""):
     exp = ET.SubElement(root, "Experience")
     exp.set("name", exp_xml["ExperienceName" + ind])
@@ -179,9 +186,11 @@ def add_exp(exp_xml, root, ind=""):
             #elem.set("name", _name)
 
 def run(listeParam):
+    print "on rentre dans run"
     command_file=listeParam[0].fichier
     command_file = comm2MAPinput(command_file)
-    command = "map -r sappli run -n C_solver_constitutive_law0d -i " + command_file
+    command = "map -r sappli run -n c_solver_constitutive_law_0d -i " + command_file
+    print(command)
     os.system(command)
     print "calcul fini, youpi !"