1 # Copyright (C) 2012-2013 EDF
3 # This file is part of SALOME HYDRO module.
5 # SALOME HYDRO module is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # SALOME HYDRO module is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with SALOME HYDRO module. If not, see <http://www.gnu.org/licenses/>.
19 from generator.generator_python import PythonGenerator
22 return {'name': 'boundary_conditions',
23 'factory': BoundaryConditionsGenerator}
25 class BoundaryConditionsGenerator(PythonGenerator):
27 This generator creates files containing associations between groups and
28 boundary conditions (.bcd files, for Boundary Conditions Definition).
29 Those files contain one line per group, each line containing four fields
30 separated by spaces: LIHBOR LIUBOR LIVBOR GROUP.
31 LIHBOR, LIUBOR and LIVBOR are integer values, GROUP is a string (the name of
39 def gener(self, obj, format = 'brut', config = None):
41 self.text = PythonGenerator.gener(self, obj, format)
44 def generPROC_ETAPE(self, obj):
46 for keyword in obj.mc_liste:
47 group_dict[keyword.nom] = keyword.valeur
48 self.group_list.append(group_dict)
49 return PythonGenerator.generPROC_ETAPE(self, obj)
51 def writeDefault(self, basefilename):
52 output_filename = os.path.splitext(basefilename)[0] + ".bcd"
53 f = open(output_filename, 'w')
54 f.write("%d\n" % len(self.group_list))
55 for group_dict in self.group_list:
56 f.write("%(LIHBOR)d %(LIUBOR)d %(LIVBOR)d %(GROUP)s\n" % group_dict)