#-----------------------------------
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'",
os.getenv('TFELHOME'),
"share/mfront/tests",
"behaviours"),
- ),
+ ),
#-----------------------------------
exp_filename_list_status = SIMP(statut='o',
typ='TXM',
)
-Parameters_list = PROC(nom = 'List of material parameters',
+Parameters_list = PROC(nom = 'Parameters_list',
#-----------------------------------
MAP_Version = SIMP(statut='o', typ='TXM', defaut=getVersion()),
#-----------------------------------
- parameters = F_Parameters(statut='o')
+ Parameters = F_Parameters(statut='o')
)
TEXTE_NEW_JDC = 'Parameters_list()'
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()
+from ConfigParser import SafeConfigParser, NoOptionError, RawConfigParser
- string = "[C_solver_constitutive_law0d]\n"
- keys =["output_directory",
+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
+ with open(input_filename) as input_file:
+ lines = input_file.readlines()
+
+ string = "[c_solver_constitutive_law0d]\n"
for line in lines:
- for key in keys:
+ for key in KEYS:
if key + "=" in line:
string += key + "=" + line.split("'")[1] + "\n"
return output_filename
+
+def writeMAPinput(dictValeur):
+ """
+ """
+ config = RawConfigParser()
+
+ config.add_section("c_solver_constitutive_law0d")
+ for key, value in dictValeur.iteritems():
+ if key in KEYS:
+ config.set("c_solver_constitutive_law0d", key, value)
+ with open("toto.input",'w') as f_out :
+ config.write(f_out)
+
def run(editor):
print ('je rentre dans run')
+ print editor.fichier
command_file = "/home/C41270/MAPinput_test.comm" # TODO: nom en dur
command_file = comm2MAPinput(command_file)
#typeDeCata='XML'
catalogues=(
('MapIdentification','MAP file',os.path.join(repIni,'cata_map_cl0d.py'),'MapIdentification','python'),
- ('MapIdentification','Experiences plan',os.path.join(repIni,'cata_map_cl0d_exp.py'),'python','python'),
- ('MapIdentification','Material parameters',os.path.join(repIni,'cata_map_cl0d_param.py'),'python','python'),
+ ('MapIdentification','Experiences plan',os.path.join(repIni,'cata_map_cl0d_exp.py'),'MapIdentificationTMP','python'),
+ ('MapIdentification','Material parameters',os.path.join(repIni,'cata_map_cl0d_param.py'),'MapIdentificationTMP','python'),
)
catalogues_exp=(
from .generator_python import PythonGenerator
+from MapIdentification.mesScripts_MAPIDENTIFICATION import MAP_KEYS
+from ConfigParser import RawConfigParser
+
def entryPoint():
"""
Retourne les informations necessaires pour le chargeur de plugins
'factory' : MapIdentificationGenerator,
}
-
class MapIdentificationGenerator(PythonGenerator):
"""
Ce generateur parcourt un objet de type JDC et produit
def gener(self,obj,format='brut',config=None,appli=None):
self.initDico()
self.text=PythonGenerator.gener(self,obj,format)
- #if obj.isValid() :self.genereMap()
- self.genereMap()
return self.text
-
- def genereMap(self) :
- '''
- Prepare le contenu du fichier de parametres python
- '''
- print ('ds genereMap')
-
-
def initDico(self) :
if not hasattr(self,'schema') : self.schema=""
self.dictParam={}
self.dictValeur={}
-
+
def writeDefault(self, fn):
- #fileEXE = fn[:fn.rfind(".")] + '.py'
- #f = open( str(fileEXE), 'wb')
- #f.write( self.texteEXE )
- #f.close()
- print ('ds writeDefault')
- print (self.dictValeur)
+ """Convert comm file into MAP input file (INI)"""
+ config = RawConfigParser()
+
+ config.add_section("c_solver_constitutive_law0d")
+ for key, value in self.dictValeur.iteritems():
+ if key in KEYS:
+ config.set("c_solver_constitutive_law0d", key, value)
- def generMCSIMP(self,obj) :
- """
- Convertit un objet MCSIMP en texte python
- Remplit le dictionnaire des MCSIMP
- """
-
- if obj.getGenealogie()[0][-6:-1]=="_PARA":
- self.dictParam[obj.nom]=obj.valeur
- else :
- self.dictValeur[obj.nom]=obj.valeur
- s=PythonGenerator.generMCSIMP(self,obj)
- return s
-
-
+ input_filname = os.path.splitext(fn)[0] + ".input"
+ with open(input_filname,'w') as f_out :
+ config.write(f_out)