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):
#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"):
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)
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":
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
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