~ubuntu-branches/ubuntu/precise/code-saturne/precise

« back to all changes in this revision

Viewing changes to gui/Pages/SolutionDomainModel.py

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-24 00:00:08 UTC
  • mfrom: (6.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20111124000008-2vo99e38267942q5
Tags: 2.1.0-3
Install a missing file

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: iso-8859-1 -*-
2
 
#
 
1
# -*- coding: utf-8 -*-
 
2
 
3
3
#-------------------------------------------------------------------------------
4
 
#
5
 
#     This file is part of the Code_Saturne User Interface, element of the
6
 
#     Code_Saturne CFD tool.
7
 
#
8
 
#     Copyright (C) 1998-2009 EDF S.A., France
9
 
#
10
 
#     contact: saturne-support@edf.fr
11
 
#
12
 
#     The Code_Saturne User Interface is free software; you can redistribute it
13
 
#     and/or modify it under the terms of the GNU General Public License
14
 
#     as published by the Free Software Foundation; either version 2 of
15
 
#     the License, or (at your option) any later version.
16
 
#
17
 
#     The Code_Saturne User Interface is distributed in the hope that it will be
18
 
#     useful, but WITHOUT ANY WARRANTY; without even the implied warranty
19
 
#     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 
#     GNU General Public License for more details.
21
 
#
22
 
#     You should have received a copy of the GNU General Public License
23
 
#     along with the Code_Saturne Kernel; if not, write to the
24
 
#     Free Software Foundation, Inc.,
25
 
#     51 Franklin St, Fifth Floor,
26
 
#     Boston, MA  02110-1301  USA
27
 
#
 
4
 
 
5
# This file is part of Code_Saturne, a general-purpose CFD tool.
 
6
#
 
7
# Copyright (C) 1998-2011 EDF S.A.
 
8
#
 
9
# This program is free software; you can redistribute it and/or modify it under
 
10
# the terms of the GNU General Public License as published by the Free Software
 
11
# Foundation; either version 2 of the License, or (at your option) any later
 
12
# version.
 
13
#
 
14
# This program is distributed in the hope that it will be useful, but WITHOUT
 
15
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
16
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
17
# details.
 
18
#
 
19
# You should have received a copy of the GNU General Public License along with
 
20
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 
21
# Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
22
 
28
23
#-------------------------------------------------------------------------------
29
24
 
30
25
"""
31
 
This module defines the XML calls for ecs execution
 
26
This module defines the XML calls for preprocessor execution
32
27
This module contains the following classes and function:
33
28
- MeshModel
34
29
- SolutionDomainModel
49
44
from Base.XMLmodel import ModelTest
50
45
 
51
46
#-------------------------------------------------------------------------------
 
47
# Utility function
 
48
#-------------------------------------------------------------------------------
 
49
 
 
50
def RelOrAbsPath(path, case_dir):
 
51
    """
 
52
    Return a relative filepath in a same study, an absolute path otherwise.
 
53
    """
 
54
 
 
55
    study_dir = os.path.split(case_dir)[0]
 
56
 
 
57
    if path.find(study_dir) == 0:
 
58
 
 
59
        if hasattr(os.path, 'relpath'):
 
60
            return os.path.relpath(path, case_dir)
 
61
 
 
62
        elif path.find(case_dir) == 0:
 
63
            return path[len(case_dir)+1:]
 
64
 
 
65
        else:
 
66
            return os.path.join('..', path[len(study_dir)+1:])
 
67
 
 
68
    else:
 
69
        return path
 
70
 
 
71
#-------------------------------------------------------------------------------
52
72
# Class Mesh Model
53
73
#-------------------------------------------------------------------------------
54
74
 
62
82
 
63
83
        Initialize the dictionary file extension => format.
64
84
        """
65
 
        self.ext = {}
66
 
        self.ext['case']  = "ensight"
67
 
        self.ext['cgns']  = "cgns"
68
 
        self.ext['des']   = "des"
69
 
        self.ext['med']   = "med"
70
 
        self.ext['msh']   = "gmsh"
71
 
        self.ext['neu']   = "gambit"
72
 
        self.ext['ccm']   = "ccm"
73
 
        self.ext['ngeom'] = "ngeom"
74
 
        self.ext['unv']   = "ideas"
75
 
        self.ext['mesh']  = "meta"
 
85
        self.ext = {'case':'ensight',
 
86
                    'cgns':'cgns',
 
87
                    'des':'des',
 
88
                    'med':'med',
 
89
                    'msh':'gmsh',
 
90
                    'neu':'gambit',
 
91
                    'ccm':'ccm',
 
92
                    'ngeom':'ngeom',
 
93
                    'unv':'ideas'}
76
94
 
77
95
 
78
96
    def getMeshExtension(self, mesh):
122
140
        Public method.
123
141
 
124
142
        @return: List of number, format and description for view of popup.
125
 
        @rtype: C{List} of C{3-tuple}
 
143
        @rtype: C{List} of C{2-tuple}
126
144
        """
127
 
        list = [(0,  'ensight', 'EnSight (6 or Gold) ".case"' ),
128
 
                (1,  'cgns',    'CGNS ".cgns"'                ),
129
 
                (2,  'des',     'Simail (NOPO) ".des"'        ),
130
 
                (3,  'med',     'MED ".med"'                  ),
131
 
                (4,  'gmsh',    'Gmsh ".msh"'                 ),
132
 
                (5,  'gambit',  'GAMBIT Neutral ".neu"'       ),
133
 
                (6,  'ccm',     'STAR-CCM+ ".ccm"'            ),
134
 
                (7,  'ngeom',   'pro-STAR/STAR4 ".ngeom"'     ),
135
 
                (8,  'ideas',   'I-deas universal ".unv"'     ),
136
 
                (9,  'meta',    'Meta-mesh file ".mesh"'      )]
 
145
        list = [('ensight', 'EnSight',          ' (*.case)' ),
 
146
                ('cgns',    'CGNS',             ' (*.cgns)' ),
 
147
                ('des',     'Simail/NOPO',      ' (*.des)'  ),
 
148
                ('med',     'MED',              ' (*.med)'  ),
 
149
                ('gmsh',    'Gmsh',             ' (*.msh)'  ),
 
150
                ('gambit',  'GAMBIT Neutral',   ' (*.neu)'  ),
 
151
                ('ccm',     'STAR-CCM+',        ' (*.ccm)'  ),
 
152
                ('ngeom',   'pro-STAR/STAR4',   ' (*.ngeom)'),
 
153
                ('ideas',   'I-deas universal', ' (*.unv)'  )]
137
154
 
138
155
        return list
139
156
 
140
157
 
141
 
    def getMeshFormatDescription(self, format):
142
 
        """
143
 
        Public method.
144
 
 
145
 
        @type format: C{String}
146
 
        @param format: name of the I{format} (ensight, cgns,...)
147
 
        @return: Description of I{format}.
148
 
        @rtype: C{String}
149
 
        """
150
 
        label = ''
151
 
        for line in self.getBuildFormatList():
152
 
            if format == line[1]:
153
 
                label = line[2]
154
 
        return label
155
 
 
156
 
 
157
158
    def getFileFormatList(self):
158
159
        """
159
160
        Public method.
165
166
                ("EnSight (6 or Gold) files", "*.case" ),
166
167
                ("CGNS files",                "*.cgns" ),
167
168
                ("Simail (NOPO) files",       "*.des"  ),
168
 
                ("MED  files",                "*.med"  ),
 
169
                ("MED files",                 "*.med"  ),
169
170
                ("GMSH files",                "*.msh"  ),
170
171
                ("GAMBIT Neutral files",      "*.neu"  ),
171
172
                ("STAR-CCM+",                 "*.ccm"  ),
172
173
                ("pro-STAR/STAR4 files",      "*.ngeom"),
173
 
                ("I-deas universal files",    "*.unv"  ),
174
 
                ("Meta-mesh files",           "*.mesh" ) ]
 
174
                ("I-deas universal files",    "*.unv"  )]
175
175
 
176
176
        return list
177
177
 
193
193
 
194
194
        self.node_ecs        = self.case.xmlGetNode('solution_domain')
195
195
        self.node_meshes     = self.node_ecs.xmlInitNode('meshes_list')
196
 
        self.node_join       = self.node_ecs.xmlInitNode('join_meshes', "status")
197
196
        self.node_cut        = self.node_ecs.xmlInitNode('faces_cutting', "status")
198
 
        self.node_orient     = self.node_ecs.xmlInitNode('reorientation', "status")
199
 
        self.node_perio      = self.node_ecs.xmlInitNode('periodic_boundary')
 
197
        self.node_join       = self.node_ecs.xmlInitNode('joining')
 
198
        self.node_perio      = self.node_ecs.xmlInitNode('periodicity')
200
199
        self.node_standalone = self.node_ecs.xmlInitNode('standalone')
201
 
##        self.node_select     = self.node_standalone.xmlInitNode('faces_select', "status")
202
200
 
203
201
 
204
202
#************************* Private methods *****************************
208
206
        Return a dictionary with default values
209
207
        """
210
208
        defvalue = {}
211
 
        defvalue['join_status']    = "off"
212
209
        defvalue['cutting_status'] = "off"
213
 
        defvalue['reorientation']  = "off"
214
210
        defvalue['select_status']  = "off"
215
 
        defvalue['color']          = ""
216
 
        defvalue['group']          = ""
217
 
        defvalue['reverse']        = "off"
 
211
        defvalue['selector']       = "all[]"
218
212
        defvalue['fraction']       = 0.1
219
 
        defvalue['plan']           = 0.8
220
 
        defvalue['semiconf']       = "off"
 
213
        defvalue['plane']          = 25.0
 
214
        defvalue['verbosity']      = 1
 
215
        defvalue['visualization']  = 1
221
216
        defvalue['angle']          = 0.01
222
217
        defvalue['syrth_status']   = "off"
223
218
        defvalue['syrth_mesh_2d']  = "off"
225
220
        defvalue['verif_mail']     = "on"
226
221
        defvalue['postprocessing_format'] = "EnSight"
227
222
        defvalue['postprocessing_options'] = "binary"
228
 
        defvalue['dir_cas']        = "cas_defaut"
 
223
        defvalue['dir_cas']        = "default_case"
229
224
        defvalue['poly_status']    = "off"
230
225
        defvalue['perio_mode']     = "translation"
231
226
        defvalue['transfo_val']    = 0.0
233
228
        return defvalue
234
229
 
235
230
 
236
 
    def _updateBatchScriptFile(self, keyword):
237
 
        """
238
 
        Update, for keyword, the backup file if it's ready to run.
239
 
        """
240
 
        self.isInList(keyword,('MESH',
241
 
                               'COMMAND_REORIENT',
242
 
                               'COMMAND_JOIN',
243
 
                               'COMMAND_CWF',
244
 
                               'COMMAND_PERIO',
245
 
                               'CWF_OFF',
246
 
                               'JOIN_OFF',
247
 
                               'PERIO_OFF'))
248
 
        key = self.case['computer']
249
 
        if key:
250
 
            if not self.case['batchScript'][key]: return
 
231
    def _getMeshNode(self, mesh):
 
232
        """
 
233
        Public method. Return the node matching a mesh.
 
234
        """
 
235
        nodeList = self.node_meshes.xmlGetNodeList('mesh', 'name')
 
236
        for node in nodeList:
 
237
            name = node['name']
 
238
            path = node['path']
 
239
            if path == '':
 
240
                path = None
 
241
            if (name, path) == mesh:
 
242
                return node
251
243
 
252
 
            from BatchRunningModel import BatchRunningModel
253
 
            batch = BatchRunningModel(self.case)
254
 
            if keyword in ('CWF_OFF', 'JOIN_OFF', 'PERIO_OFF'):
255
 
                cmd = string.split(keyword,'_')[:1][0]
256
 
                keyword = 'COMMAND_' + str(cmd)
257
 
                batch.dicoValues[keyword] = ''
258
 
            batch.initializeBatchScriptFile()
259
 
            batch.updateBatchScriptFile(keyword)
260
 
            del BatchRunningModel
 
244
        msg = "There is an error: this value " + str(mesh) + "\n"\
 
245
            "is not in list " + str(nodeList) + "\n"
 
246
        raise ValueError(msg)
261
247
 
262
248
 
263
249
#To follow : private methods to get or put faces
267
253
        """
268
254
        Private method: Return node corresponding at item "tag"
269
255
        """
270
 
        self.isInList(tagName, ('faces_join', 'faces_select', 'faces_periodic'))
271
 
        if tagName == 'faces_join':
 
256
        self.isInList(tagName, ('face_joining', 'face_periodicity'))
 
257
        if tagName == 'face_joining':
272
258
            node = self.node_join
273
 
        elif tagName == 'faces_select':
274
 
            node = self.node_standalone
275
 
        elif tagName == 'faces_periodic':
 
259
        elif tagName == 'face_periodicity':
276
260
            node = self.node_perio
277
261
        return node
278
262
 
279
263
 
280
 
    def _updateJoinSelectionsNumbers(self):
 
264
    def _getJoinNode(self, join_id):
 
265
        """
 
266
        Get node for a given joining
 
267
        """
 
268
        node = None
 
269
        listNode = self.node_join.xmlGetNodeList('face_joining')
 
270
        if join_id < len(listNode):
 
271
            node = listNode[join_id]
 
272
 
 
273
        return node
 
274
 
 
275
    def _updateJoinSelectionNumbers(self):
281
276
        """
282
277
        Update names of join selection
283
278
        """
284
 
        listNode = self.node_join.xmlGetNodeList('faces_join')
 
279
        listNode = self.node_join.xmlGetNodeList('face_joining')
285
280
        i = 0
286
281
        for node in listNode:
287
282
            i = i + 1
289
284
                node['name'] = str(i)
290
285
 
291
286
 
292
 
    def getJoinSelectionsNumber(self):
293
 
        """
294
 
        Public method.
295
 
 
296
 
        @return: number of join faces selections
297
 
        @rtype: C{int}
298
 
        """
299
 
        return len(self.node_join.xmlGetNodeList('faces_join'))
300
 
 
301
 
 
302
 
    def _addFacesSelect(self, node, select):
 
287
    def _addJoinSelect(self, node, select):
303
288
        """
304
289
        Private method: Add faces to node (join, periodic) with dictionary select.
305
290
        """
306
 
        for sel, txt in [ (select['color'],    'faces_color'),
307
 
                          (select['group'],    'faces_group'),
308
 
                          (select['fraction'], 'faces_fraction'),
309
 
                          (select['plan'],     'faces_plan')]:
 
291
        for sel, txt in [ (select['selector'],  'selector'),
 
292
                          (select['fraction'],  'fraction'),
 
293
                          (select['plane'],     'plane'),
 
294
                          (select['verbosity'], 'verbosity'),
 
295
                          (select['visualization'], 'visualization')]:
310
296
            if sel:
311
297
                node.xmlSetData(txt, sel)
312
298
            else:
313
299
                node.xmlRemoveChild(txt)
314
300
 
315
 
        if select['reverse'] == 'on':
316
 
            node_revers = node.xmlInitNode('faces_reverse', status='on')
317
 
        else:
318
 
            node.xmlRemoveChild('faces_reverse')
319
 
 
320
 
        if select['semiconf'] == 'on':
321
 
            node_semiconf = node.xmlInitNode('faces_semi_conf', status='on')
322
 
        else:
323
 
            node.xmlRemoveChild('faces_semi_conf')
324
 
 
325
301
 
326
302
    def _getFaces(self, node):
327
303
        """
328
 
        Private method: Return values found for color, group .. for node "node"
 
304
        Private method: Return values found for joining for a given node
329
305
        """
330
306
        default = {}
331
 
        default['color'] =""
332
 
        default['group'] = ""
 
307
        default['selector'] =""
333
308
        default['fraction'] = ""
334
 
        default['plan'] = ""
335
 
        default['reverse'] = ""
336
 
        default['semiconf'] = ""
 
309
        default['plane'] = ""
 
310
        default['verbosity'] = ""
 
311
        default['visualization'] = ""
337
312
 
338
313
        if node:
339
 
            default['color']    = node.xmlGetString('faces_color')
340
 
            default['group']    = node.xmlGetString('faces_group')
341
 
            default['fraction'] = node.xmlGetString('faces_fraction')
342
 
            default['plan']     = node.xmlGetString('faces_plan')
343
 
 
344
 
            n_revers = node.xmlGetNode('faces_reverse', 'status')
345
 
 
346
 
            if n_revers:
347
 
                default['reverse'] = n_revers['status']
348
 
            else:
349
 
                default['reverse'] = "off"
350
 
 
351
 
            n_semi_conf = node.xmlGetNode('faces_semi_conf', 'status')
352
 
 
353
 
            if n_semi_conf:
354
 
                default['semiconf'] = n_semi_conf['status']
355
 
            else:
356
 
                default['semiconf'] = "off"
357
 
        if default['color'] == '' and default['group'] == '' and default['fraction'] == ""\
358
 
                                  and default['plan'] == "" and default['reverse'] == "off" \
359
 
                                  and default['semiconf'] == "off":
 
314
            default['selector']  = node.xmlGetString('selector')
 
315
            default['fraction']  = node.xmlGetString('fraction')
 
316
            default['plane']     = node.xmlGetString('plane')
 
317
            default['verbosity'] = node.xmlGetString('verbosity')
 
318
            default['visualization'] = node.xmlGetString('visualization')
 
319
            if not default['selector']:
 
320
                default['selector'] = "all[]"
 
321
            if not default['fraction']:
 
322
                default['fraction'] = 0.1
 
323
            if not default['plane']:
 
324
                default['plane'] = 25
 
325
            if not default['verbosity']:
 
326
                default['verbosity'] = 1
 
327
            if not default['visualization']:
 
328
                default['visualization'] = 1
 
329
 
 
330
        else:
360
331
            default = {}
361
332
 
362
333
        return default
363
334
 
364
335
 
365
 
    def _removeChildren(self, node):
 
336
    def _removeJoinChildren(self, node):
366
337
        """
367
338
        Private method: Remove all child nodes of node for one selection
368
339
        """
369
 
        for tag in ('faces_color',
370
 
                    'faces_group',
371
 
                    'faces_fraction',
372
 
                    'faces_plan',
373
 
                    'faces_reverse',
374
 
                    'faces_semi_conf'):
 
340
        for tag in ('selector',
 
341
                    'fraction',
 
342
                    'plane',
 
343
                    'verbosity',
 
344
                    'visualization',):
375
345
            node.xmlRemoveChild(tag)
376
346
 
377
347
 
378
 
    def _getLineCommand(self, node):
379
 
        """
380
 
        Private method: Get color group faces and revers satus and fraction
381
 
        and plan datas for ommand line to preprocessor execution
382
 
        """
383
 
        line = ""
384
 
        coul = node.xmlGetString('faces_color')
385
 
        grp = node.xmlGetString('faces_group')
386
 
        n_revers = node.xmlGetNode('faces_reverse', 'status')
387
 
        n_semi_conf = node.xmlGetNode('faces_semi_conf',' status')
388
 
 
389
 
        if coul:
390
 
            line += " --color " + coul
391
 
        if grp:
392
 
            line += " --group " + grp
393
 
        if n_revers and n_revers['status'] == "on":
394
 
            line += " --invsel"
395
 
        if n_semi_conf and n_semi_conf['status'] == "on":
396
 
            line += " --semi-conf"
397
 
 
398
 
        return line
399
 
 
400
 
 
401
348
#To follow : private methods for periodicity:
402
349
#===========================================
403
350
 
404
 
 
405
 
    def _setPeriodicNewMode(self, perio_name, new_mode):
406
 
        """
407
 
        Private method: Set node and mode of periodicity for transformation named 'perio_name'
408
 
        """
409
 
        #self.isInList(perio_name, ("0", "1", "2", "3"))
410
 
        #self.isLowerOrEqual(int(perio_name), int(self.getPeriodicityNumber()))
411
 
        self.isInList(perio_name, self.getPeriodicityListName())
412
 
        node = self.node_perio.xmlGetNode('transformation', name=perio_name)
413
 
        node['mode'] = new_mode
414
 
 
415
 
 
416
 
    def _setTranslationDefault(self, perio_name):
 
351
    def _getPerioNode(self, perio_id):
 
352
        """
 
353
        Get node for a given periodicity
 
354
        """
 
355
        node = None
 
356
        listNode = self.node_perio.xmlGetNodeList('face_periodicity')
 
357
        if perio_id < len(listNode):
 
358
            node = listNode[perio_id]
 
359
 
 
360
        return node
 
361
 
 
362
    def _updatePerioSelectionNumbers(self):
 
363
        """
 
364
        Update names of periodicity selections
 
365
        """
 
366
        listNode = self.node_perio.xmlGetNodeList('face_periodicity')
 
367
        i = 0
 
368
        for node in listNode:
 
369
            i = i + 1
 
370
            if int(node['name']) > i:
 
371
                node['name'] = str(i)
 
372
 
 
373
 
 
374
    def _setPeriodicNewMode(self, perio_id, new_mode):
 
375
        """
 
376
        Private method: Set node and mode of given periodicity'
 
377
        """
 
378
        listNode = self.node_perio.xmlGetNodeList('face_periodicity')
 
379
        if perio_id < len(listNode):
 
380
            node = listNode[perio_id]
 
381
            node['mode'] = new_mode
 
382
 
 
383
 
 
384
    def _setTranslationDefault(self, perio_id):
417
385
        """
418
386
        Private method: Put default values of translation for periodic translation
419
387
        """
420
 
        node = self.node_perio.xmlGetNode('transformation', name=perio_name)
 
388
        node = self._getPerioNode(perio_id)
 
389
 
421
390
        if node:
422
391
            nList = node.xmlInitChildNodeList('translation')
423
392
            for n in nList:
426
395
                n.xmlSetData('translation_z', self.defaultValues()['transfo_val'])
427
396
 
428
397
 
429
 
    def _setRotation1Default(self, perio_name):
430
 
        """
431
 
        Private method: Put default values of translation for periodic translation
432
 
        """
433
 
        node = self.node_perio.xmlGetNode('transformation', name=perio_name)
434
 
        nList = node.xmlInitChildNodeList('rotation1')
435
 
        for n in nList:
436
 
            n.xmlSetData('rotation_angle', self.defaultValues()['transfo_val'])
437
 
            n.xmlSetData('rotation_x', self.defaultValues()['transfo_val'])
438
 
            n.xmlSetData('rotation_y', self.defaultValues()['transfo_val'])
439
 
            n.xmlSetData('rotation_z', self.defaultValues()['transfo_val'])
440
 
            n.xmlSetData('rotation_center_x', self.defaultValues()['transfo_val'])
441
 
            n.xmlSetData('rotation_center_y', self.defaultValues()['transfo_val'])
442
 
            n.xmlSetData('rotation_center_z', self.defaultValues()['transfo_val'])
443
 
 
444
 
 
445
 
    def _setRotation2Default(self, perio_name):
446
 
        """
447
 
        Private method: Put default values of translation for periodic translation
448
 
        """
449
 
        node = self.node_perio.xmlGetNode('transformation', name=perio_name)
450
 
        nList = node.xmlInitChildNodeList('rotation2')
451
 
        for n in nList:
452
 
            for txt in ('rotation_matrix_11', 'rotation_matrix_12', 'rotation_matrix_13',
453
 
                        'rotation_matrix_21', 'rotation_matrix_22', 'rotation_matrix_23',
454
 
                        'rotation_matrix_31', 'rotation_matrix_32', 'rotation_matrix_33',
455
 
                        'rotation_center_y', 'rotation_center_z', ):
456
 
                n.xmlSetData(txt, self.defaultValues()['transfo_val'])
 
398
    def _setRotationDefault(self, perio_id):
 
399
        """
 
400
        Private method: Put default values of translation for periodic translation
 
401
        """
 
402
        node = self._getPerioNode(perio_id)
 
403
 
 
404
        if node:
 
405
            nList = node.xmlInitChildNodeList('rotation')
 
406
            for n in nList:
 
407
                n.xmlSetData('angle', self.defaultValues()['transfo_val'])
 
408
                n.xmlSetData('axis_x', self.defaultValues()['transfo_val'])
 
409
                n.xmlSetData('axis_y', self.defaultValues()['transfo_val'])
 
410
                n.xmlSetData('axis_z', self.defaultValues()['transfo_val'])
 
411
                n.xmlSetData('invariant_x', self.defaultValues()['transfo_val'])
 
412
                n.xmlSetData('invariant_y', self.defaultValues()['transfo_val'])
 
413
                n.xmlSetData('invariant_z', self.defaultValues()['transfo_val'])
 
414
 
 
415
 
 
416
    def _setMixedDefault(self, perio_id):
 
417
        """
 
418
        Private method: Put default values of translation for periodic translation
 
419
        """
 
420
        node = self._getPerioNode(perio_id)
 
421
 
 
422
        if node:
 
423
            nList = node.xmlInitChildNodeList('mixed')
 
424
            for n in nList:
 
425
                for txt in ('matrix_12', 'matrix_13', 'matrix_14',
 
426
                            'matrix_21', 'matrix_23', 'matrix_24',
 
427
                            'matrix_31', 'matrix_32', 'matrix_34'):
 
428
                    n.xmlSetData(txt, 0.0)
 
429
                for txt in ('matrix_11', 'matrix_22', 'matrix_33'):
 
430
                    n.xmlSetData(txt, 1.0)
457
431
 
458
432
 
459
433
#************************* Methods callable by users*****************************
460
434
 
 
435
# Methods to manage the mesh_input path
 
436
#======================================
 
437
 
 
438
    def getMeshInput(self):
 
439
        """
 
440
        Public method. Return the mesh_input file or directory path.
 
441
        """
 
442
        mesh_input = self.node_ecs.xmlGetNode('mesh_input', 'path')
 
443
        if mesh_input:
 
444
            return mesh_input['path']
 
445
        else:
 
446
            return None
 
447
 
 
448
 
 
449
    def setMeshInput(self, mesh_input):
 
450
        """
 
451
        Public method. Add mesh_input path name in xml file.
 
452
        """
 
453
 
 
454
        if mesh_input == '':
 
455
            mesh_input = None
 
456
 
 
457
        node = self.node_ecs.xmlInitNode('mesh_input', 'path')
 
458
        if mesh_input:
 
459
            node['path'] = mesh_input
 
460
        else:
 
461
            node.xmlRemoveNode()
 
462
 
 
463
 
461
464
# Methods to manage meshes :
462
465
#=========================
463
466
 
464
 
    def addMesh(self, mesh, format=None):
 
467
    def addMesh(self, mesh):
465
468
        """
466
469
        Public method. Add mesh name in xml file.
467
470
        """
468
471
        self.isNotInList(mesh, self.getMeshList())
469
 
        if not format:
470
 
            format = MeshModel().getMeshFormat(mesh)
 
472
 
 
473
        if mesh[1] != None:
 
474
            self.node_meshes.xmlInitNode('mesh', name=mesh[0], path=mesh[1])
471
475
        else:
472
 
            self.isInList(format, MeshModel().ext.values())
473
 
 
474
 
        self.node_meshes.xmlInitNode('mesh', name=mesh, format=format)
475
 
        self._updateBatchScriptFile('MESH')
 
476
            self.node_meshes.xmlInitNode('mesh', name=mesh[0])
476
477
 
477
478
 
478
479
    def delMesh(self, mesh):
479
480
        """
480
481
        Public method. Delete node for mesh named "mesh" in xml file
481
482
        """
482
 
        self.isInList(mesh, self.getMeshList())
483
 
        nodeList = self.node_meshes.xmlGetNodeList('mesh', 'name')
484
 
        for node in nodeList:
485
 
            if node['name'] == mesh:
486
 
                node.xmlRemoveNode()
487
 
        self._updateBatchScriptFile('MESH')
 
483
        node = self._getMeshNode(mesh)
 
484
        node.xmlRemoveNode()
488
485
 
489
486
 
490
487
    def getMeshList(self):
494
491
        meshList = []
495
492
        nodeList = self.node_meshes.xmlGetNodeList('mesh', 'name')
496
493
        for node in nodeList:
497
 
            meshList.append(node['name'])
 
494
            name = node['name']
 
495
            path = node['path']
 
496
            if path == '':
 
497
                path = None
 
498
            meshList.append((name, path))
498
499
        return meshList
499
500
 
500
501
 
 
502
    def setMeshFormat(self, mesh, format):
 
503
        """
 
504
        Public method. Set the mesh format.
 
505
        """
 
506
        node = self._getMeshNode(mesh)
 
507
        if not format or format == MeshModel().getMeshFormat(mesh[0]):
 
508
            del node['format']
 
509
        else:
 
510
            node['format'] = format
 
511
 
 
512
 
501
513
    def getMeshFormat(self, mesh):
502
514
        """
503
 
        Public method. Return the mesh name format recorded in the case.
504
 
        """
505
 
        self.isInList(mesh, self.getMeshList())
506
 
        return self.node_meshes.xmlGetNode('mesh', name=mesh)['format']
507
 
 
508
 
 
509
 
    def getMeshExtendedFormat(self, mesh):
510
 
        """
511
 
        Public method. Return the mesh extended format.
512
 
        """
513
 
        fmt = MeshModel().getMeshFormat(mesh)
514
 
        for line in MeshModel().getBuildFormatList():
515
 
            if fmt == line[1]:
516
 
                label = line[2]
517
 
        return label
518
 
 
519
 
 
520
 
    def setMeshNumber(self, mesh, num):
521
 
        """
522
 
        Public method. Put the mesh number.
523
 
        """
524
 
        self.isInList(mesh, self.getMeshList())
525
 
        self.isInt(num)
526
 
        self.isGreater(num, 0)
527
 
 
528
 
        self.node_meshes.xmlGetNode('mesh', name=mesh)['num'] = num
529
 
        self._updateBatchScriptFile('MESH')
530
 
 
531
 
 
532
 
    def getMeshNumber(self, mesh):
 
515
        Public method. Return the mesh format recorded in the case.
 
516
        """
 
517
        node = self._getMeshNode(mesh)
 
518
        format = node['format']
 
519
        if not format:
 
520
            format = MeshModel().getMeshFormat(mesh[0])
 
521
        return format
 
522
 
 
523
 
 
524
    def setMeshNumbers(self, mesh, num):
 
525
        """
 
526
        Public method. Set the mesh number(s).
 
527
        """
 
528
        node = self._getMeshNode(mesh)
 
529
        if not num:
 
530
            del node['num']
 
531
        else:
 
532
            node['num'] = num
 
533
 
 
534
 
 
535
    def getMeshNumbers(self, mesh):
533
536
        """
534
537
        Public method. Return the mesh number recorded in the case.
535
538
        """
536
 
        self.isInList(mesh, self.getMeshList())
537
 
        num = self.node_meshes.xmlGetNode('mesh', name=mesh)['num']
538
 
        if num:
539
 
            num = int(num)
540
 
        return num
 
539
        node = self._getMeshNode(mesh)
 
540
        return node['num']
541
541
 
542
542
 
543
543
    def setMeshGroupCells(self, mesh, grp_cel):
544
544
        """
545
545
        Public method. Put the grp-cel option.
546
546
        """
547
 
        self.isInList(mesh, self.getMeshList())
 
547
        node = self._getMeshNode(mesh)
548
548
        self.isInList(grp_cel, ('off', 'section', 'zone'))
549
549
 
550
550
        if grp_cel == "off":
551
 
            del self.node_meshes.xmlGetNode('mesh', name=mesh)['grp_cel']
552
 
        else:
553
 
            self.node_meshes.xmlGetNode('mesh', name=mesh)['grp_cel'] = grp_cel
554
 
        self._updateBatchScriptFile('MESH')
 
551
            del node['grp_cel']
 
552
        else:
 
553
            node['grp_cel'] = grp_cel
 
554
 
 
555
 
 
556
    def setMeshReorient(self, mesh, reorient):
 
557
        """
 
558
        Public method. Put the grp-cel option.
 
559
        """
 
560
        node = self._getMeshNode(mesh)
 
561
 
 
562
        if reorient == False:
 
563
            del node['reorient']
 
564
        else:
 
565
            node['reorient'] = 'on'
 
566
 
 
567
 
 
568
    def getMeshReorient(self, mesh):
 
569
        """
 
570
        Public method. Return the mesh 'grp-cel' sub-option recorded in the case.
 
571
        """
 
572
        node = self._getMeshNode(mesh)
 
573
        reorient = False
 
574
        if node['reorient'] == 'on':
 
575
            reorient = True
 
576
        return reorient
555
577
 
556
578
 
557
579
    def getMeshGroupCells(self, mesh):
565
587
        """
566
588
        Public method. Put the 'grp-fac' sub-option.
567
589
        """
568
 
        self.isInList(mesh, self.getMeshList())
 
590
        node = self._getMeshNode(mesh)
569
591
        self.isInList(grp_fac, ('off', 'section', 'zone'))
570
592
 
571
593
        if grp_fac == "off":
572
 
            del self.node_meshes.xmlGetNode('mesh', name=mesh)['grp_fac']
 
594
            del node['grp_fac']
573
595
        else:
574
 
            self.node_meshes.xmlGetNode('mesh', name=mesh)['grp_fac'] = grp_fac
575
 
        self._updateBatchScriptFile('MESH')
 
596
            node['grp_fac'] = grp_fac
576
597
 
577
598
 
578
599
    def getMeshGroupFaces(self, mesh):
586
607
        """
587
608
        Private method. Return the mesh 'grp_fac' or 'grp_cel' sub-option recorded in the case.
588
609
        """
589
 
        self.isInList(mesh, self.getMeshList())
590
 
        grp = self.node_meshes.xmlGetNode('mesh', name=mesh)[group]
 
610
        node = self._getMeshNode(mesh)
 
611
        grp = node[group]
591
612
        if grp == None:
592
613
            grp = 'off'
593
614
        return grp
594
615
 
595
 
# Methods to manage status of all main balises :
596
 
#=============================================
597
 
 
598
 
    def getJoinMeshesStatus(self):
599
 
        """
600
 
        Get status on balise "join_meshes" from xml file
601
 
        """
602
 
        status = self.node_join['status']
603
 
        if not status:
604
 
            status = self.defaultValues()['join_status']
605
 
            self.setJoinMeshesStatus(status)
606
 
        return status
607
 
 
608
 
 
609
 
    def setJoinMeshesStatus(self, status):
610
 
        """
611
 
        Put status on balise "join_meshes" in xml file
612
 
        """
613
 
        self.isOnOff(status)
614
 
        if self.node_join:
615
 
            self.node_join['status'] = status
616
 
        else:
617
 
            self.node_join = self.node_ecs.xmlInitNode('join_meshes', status=status)
618
 
        if status == 'off':
619
 
            self._updateBatchScriptFile('JOIN_OFF')
620
 
        else:
621
 
            self._updateBatchScriptFile('COMMAND_JOIN')
622
 
 
 
616
 
 
617
    def getMeshDir(self):
 
618
        """
 
619
        Public method. Return the meshdir directory name.
 
620
        """
 
621
        meshnode = self.node_meshes.xmlGetNode('meshdir', 'name')
 
622
        if meshnode != None:
 
623
            meshdir = meshnode['name']
 
624
            if not os.path.isabs(meshdir):
 
625
                meshdir = os.path.join(self.case['case_path'], meshdir)
 
626
            meshdir = os.path.abspath(meshdir)
 
627
            return meshdir
 
628
        else:
 
629
            return None
 
630
 
 
631
 
 
632
    def setMeshDir(self, mesh_dir):
 
633
        """
 
634
        Public method. Add mesh name in xml file.
 
635
        """
 
636
 
 
637
        case_dir = self.case['case_path']
 
638
 
 
639
        if mesh_dir:
 
640
            if not os.path.isabs(mesh_dir):
 
641
                mesh_dir = os.path.join(case_dir, mesh_dir)
 
642
            mesh_dir = os.path.abspath(mesh_dir)
 
643
 
 
644
        node = self.node_meshes.xmlInitNode('meshdir', 'name')
 
645
        if mesh_dir:
 
646
            study_dir = os.path.split(case_dir)[0]
 
647
            node['name'] = RelOrAbsPath(mesh_dir, case_dir)
 
648
        else:
 
649
            node.xmlRemoveNode()
 
650
 
 
651
        old_mesh_dir = self.case['mesh_path']
 
652
        self.case['mesh_path'] = mesh_dir
 
653
 
 
654
        nodeList = self.node_meshes.xmlGetNodeList('mesh', 'name')
 
655
        for node in nodeList:
 
656
            name = node['name']
 
657
            path = node['path']
 
658
            # Rebuild absolute name
 
659
            if path != None and path !='':
 
660
                name = os.path.join(path, name)
 
661
            if not os.path.isabs(name) and old_mesh_dir != None:
 
662
                name = os.path.join(old_mesh_dir, name)
 
663
            # Split components
 
664
            if os.path.isfile(name):
 
665
                path = os.path.dirname(name)
 
666
                if mesh_dir != None:
 
667
                    index = path.find(mesh_dir)
 
668
                    if index == 0:
 
669
                        path = path[len(mesh_dir)+1:]
 
670
                if len(path) > 0:
 
671
                    node['path'] = path
 
672
                else:
 
673
                    del node['path']
 
674
 
 
675
 
 
676
 
 
677
# Methods to manage status of all main tags :
 
678
#==========================================
623
679
 
624
680
    def getCutStatus(self):
625
681
        """
626
 
        Get status on balise "faces_cutting" from xml file
 
682
        Get status on tag "faces_cutting" from xml file
627
683
        """
628
684
        status = self.node_cut['status']
629
685
        if not status:
634
690
 
635
691
    def setCutStatus(self, status):
636
692
        """
637
 
        Put status on balise "faces_cutting" in xml file
 
693
        Put status on tag "faces_cutting" in xml file
638
694
        """
639
695
        self.isOnOff(status)
640
696
        self.node_cut['status'] = status
641
 
        if status == 'off':
642
 
            self._updateBatchScriptFile('CWF_OFF')
643
 
        else:
644
 
            self._updateBatchScriptFile('COMMAND_CWF')
645
697
 
646
698
 
647
699
    def setCutAngle(self, var):
648
700
        """
649
 
        input '--cwf' parameter.
 
701
        input '--cut_warped_faces' parameter.
650
702
        """
651
703
        self.isGreaterOrEqual(var, 0.0)
652
704
        if var != self.defaultValues()['angle']:
653
705
            self.node_cut.xmlSetData('warp_angle_max', var)
654
706
        else:
655
707
            self.node_cut.xmlRemoveChild('warp_angle_max')
656
 
        self._updateBatchScriptFile('COMMAND_CWF')
657
708
 
658
709
 
659
710
    def getCutAngle(self):
660
711
        """
661
 
        get '--cwf' parameters.
 
712
        get '--cut_warped_faces' parameters.
662
713
        """
663
714
        angle = self.node_cut.xmlGetDouble('warp_angle_max')
664
715
        if angle == None:
666
717
        return angle
667
718
 
668
719
 
669
 
    def getOrientation(self):
670
 
        """
671
 
        Get status on balise "reorientation" from xml file
672
 
        """
673
 
        status = self.node_orient['status']
674
 
        if not status:
675
 
            status = self.defaultValues()['reorientation']
676
 
            self.setOrientation(status)
677
 
        return status
678
 
 
679
 
 
680
 
    def setOrientation(self, status):
681
 
        """
682
 
        Put status on balise "reorientation" in xml file
683
 
        """
684
 
        self.isOnOff(status)
685
 
        self.node_orient['status'] = status
686
 
        self._updateBatchScriptFile('COMMAND_REORIENT')
687
 
 
688
 
 
689
720
    def getSimCommStatus(self):
690
721
        """
691
 
        Get status of balise ''similation_communication' into xml file
 
722
        Get status of tag ''similation_communication' into xml file
692
723
        """
693
724
        node = self.node_standalone.xmlInitNode('simulation_communication', 'status')
694
725
        status = node['status']
700
731
 
701
732
    def setSimCommStatus(self, status):
702
733
        """
703
 
        Put status of balise ''similation_communication' into xml file
 
734
        Put status of tag ''similation_communication' into xml file
704
735
        """
705
736
        self.isOnOff(status)
706
737
        node = self.node_standalone.xmlInitNode('simulation_communication', 'status')
753
784
# Methods to manage periodicity :
754
785
#==============================
755
786
 
756
 
    def getPeriodicityListName(self):
757
 
        """
758
 
        Public method.
759
 
 
760
 
        @return: list of name of defined periodic transformation
761
 
        @rype: C{list}
762
 
        """
763
 
        l = []
764
 
        for node in self.node_perio.xmlGetNodeList('transformation'):
765
 
            l.append(node['name'])
766
 
        return l
767
 
 
768
 
 
769
 
    def getPeriodicityNumber(self):
770
 
        """
771
 
        Public method.
772
 
 
773
 
        @return: number of "periodic_boundary" markup in xml file
 
787
    def getPeriodicSelectionsCount(self):
 
788
        """
 
789
        Public method.
 
790
 
 
791
        @return: number of periodic faces selections
774
792
        @rtype: C{int}
775
793
        """
776
 
        return len(self.node_perio.xmlGetNodeList('transformation'))
777
 
 
778
 
 
779
 
    def getPeriodicityMode(self, perio_name):
 
794
        return len(self.node_perio.xmlGetNodeList('face_periodicity'))
 
795
 
 
796
 
 
797
    def getPeriodicityMode(self, perio_id):
780
798
        """
781
799
        Public method.
782
800
 
783
 
        @type perio_name: C{str}
784
 
        @param perio_name: name of the periodic boundary
785
 
        @return: mode of transformation of periodic boundary I{perio_name}
 
801
        @type perio_id: C{int}
 
802
        @param perio_id: id of the periodic boundary
 
803
        @return: mode of transformation of periodic boundary I{perio_id}
786
804
        @rtype: C{str}
787
805
        """
788
 
        self.isInList(perio_name, self.getPeriodicityListName())
 
806
        node = self._getPerioNode(perio_id)
789
807
 
790
 
        node = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
791
808
        mode = node['mode']
792
809
        if not mode:
793
810
            mode = self.defaultValues()['perio_mode']
794
 
            self.addPeriodicity(perio_name)
 
811
 
795
812
        return mode
796
813
 
797
814
 
798
 
    def addPeriodicity(self, perio_name):
799
 
        """
800
 
        Public method.
801
 
 
802
 
        Add a new transformation in periodic boundary.
803
 
 
804
 
        @type perio_name: C{str}
805
 
        @param perio_name: name of the periodic boundary
806
 
        """
807
 
        self.isNotInList(perio_name, self.getPeriodicityListName())
808
 
 
809
 
        m = self.defaultValues()['perio_mode']
810
 
        self.node_perio.xmlInitNode('transformation', mode="", name=perio_name)
811
 
        self.updatePeriodicityMode(perio_name, m)
812
 
 
813
 
 
814
 
    def updatePeriodicityMode(self, perio_name, mode):
 
815
    def updatePeriodicityMode(self, perio_id, mode):
815
816
        """
816
817
        Public method.
817
818
 
818
819
        Update transformation mode from a periodic boundary
819
820
 
820
 
        @type perio_name: C{str}
821
 
        @param perio_name: name of the periodic boundary
 
821
        @type perio_id: C{int}
 
822
        @param perio_id: id of the periodic boundary
822
823
        @type mode: C{str}
823
 
        @param mode: mode of the periodic boundary (i.e.: 'translation', 'rotation1', 'rotation2', 'tr+rota1', 'tr+rota2')
 
824
        @param mode: mode of the periodic boundary (i.e.: 'translation', 'rotation', 'mixed')
824
825
        """
825
 
        self.isInList(perio_name, self.getPeriodicityListName())
826
 
        self.isInList(mode, ('translation', 'rotation1', 'rotation2', 'tr+rota1', 'tr+rota2'))
827
 
 
828
 
        node = self.node_perio.xmlGetNode('transformation', name=perio_name)
 
826
        node = self._getPerioNode(perio_id)
 
827
 
 
828
        self.isInList(mode, ('translation', 'rotation', 'mixed'))
 
829
 
829
830
        if node['mode'] != mode:
830
831
            node['mode'] = mode
831
832
 
832
 
            if mode in ('translation', 'rotation1', 'rotation2'):
 
833
            if mode in ('translation', 'rotation', 'mixed'):
833
834
                if not node.xmlGetChildNode(mode):
834
835
                  if mode =="translation":
835
 
                      self._setTranslationDefault(perio_name)
836
 
                  elif mode =="rotation1":
837
 
                      self._setRotation1Default(perio_name)
838
 
                  elif mode =="rotation2":
839
 
                      self._setRotation2Default(perio_name)
840
 
            else:
841
 
                if mode =="tr+rota1":
842
 
                    if not node.xmlGetChildNode('translation'):
843
 
                        self._setTranslationDefault(perio_name)
844
 
                    if not node.xmlGetChildNode('rotation1'):
845
 
                        self._setRotation1Default(perio_name)
846
 
                elif mode =="tr+rota2":
847
 
                    if not node.xmlGetChildNodeList('translation'):
848
 
                        self._setTranslationDefault(perio_name)
849
 
                    if not node.xmlGetChildNodeList('rotation2'):
850
 
                        self._setRotation2Default(perio_name)
851
 
 
852
 
            self._updateBatchScriptFile('COMMAND_PERIO')
853
 
 
854
 
 
855
 
    def deletePeriodicity(self, perio_name):
 
836
                      self._setTranslationDefault(perio_id)
 
837
                  elif mode =="rotation":
 
838
                      self._setRotationDefault(perio_id)
 
839
                  elif mode =="mixed":
 
840
                      self._setMixedDefault(perio_id)
 
841
 
 
842
 
 
843
    def deletePeriodicity(self, perio_id):
856
844
        """
857
845
        Public method.
858
846
 
859
847
        Delete a transformation in periodic boundary.
860
848
 
861
 
        @type perio_name: C{str}
862
 
        @param perio_name: name of the periodic boundary
863
 
        """
864
 
        self.isInList(perio_name, self.getPeriodicityListName())
865
 
        self.node_perio.xmlGetNode('transformation', name=perio_name).xmlRemoveNode()
866
 
 
867
 
        if len(self.node_perio.xmlGetNodeList('transformation')) == 0:
868
 
            self._updateBatchScriptFile('PERIO_OFF')
869
 
        else:
870
 
            self._updateBatchScriptFile('COMMAND_PERIO')
871
 
 
872
 
 
873
 
    def changePeriodicityName(self, perio_name, new_name):
874
 
        """
875
 
        Public method.
876
 
 
877
 
        Change the label name of a periodic boundary
878
 
 
879
 
        @type perio_name: C{str}
880
 
        @param perio_name: old name of the periodic boundary
881
 
        @type new_name: C{str}
882
 
        @param new_name: new name of the periodic boundary
883
 
        """
884
 
        self.isInList(perio_name, self.getPeriodicityListName())
885
 
        node = self.node_perio.xmlGetNode('transformation', name=perio_name)
886
 
        node['name'] = new_name
887
 
 
888
 
 
889
 
    def getTranslationDirection(self, perio_name):
 
849
        @type perio_id: C{str}
 
850
        @param perio_id: name of the periodic boundary
 
851
        """
 
852
        node = self._getPerioNode(perio_id)
 
853
        node.xmlRemoveNode()
 
854
        if perio_id < self.getPeriodicSelectionsCount():
 
855
            self._updatePerioSelectionNumbers()
 
856
 
 
857
 
 
858
    def getTranslationDirection(self, perio_id):
890
859
        """
891
860
        Public method.
892
861
 
893
862
        Get values of translation for periodic translation
894
863
 
895
 
        @type perio_name: C{str}
896
 
        @param perio_name: name of the periodic boundary
 
864
        @type perio_id: C{int}
 
865
        @param perio_id: name of the periodic boundary
897
866
        @return: values of translation for periodic translation
898
867
        @rtype: 3 C{float}
899
868
        """
900
 
        self.isInList(perio_name, self.getPeriodicityListName())
 
869
        node = self._getPerioNode(perio_id)
901
870
 
902
 
        node = self.node_perio.xmlGetNode('transformation', name=perio_name)
903
871
        n = node.xmlGetChildNode('translation')
904
872
        dx = n.xmlGetString('translation_x')
905
873
        dy = n.xmlGetString('translation_y')
908
876
        return dx, dy, dz
909
877
 
910
878
 
911
 
    def setTranslationDirection(self, perio_name, dir, valcoor):
 
879
    def setTranslationDirection(self, perio_id, dir, valcoor):
912
880
        """
913
881
        Put values of translation for periodic translation
914
882
        """
915
883
        self.isFloat(valcoor)
916
 
        self.isInList(perio_name, self.getPeriodicityListName())
917
 
        self.isInList(dir, ("translation_x", "translation_y", "translation_z"))
918
 
 
919
 
        node = self.node_perio.xmlGetNode('transformation', name=perio_name)
 
884
        self.isInList(dir, ('translation_x', 'translation_y', 'translation_z'))
 
885
 
 
886
        node = self._getPerioNode(perio_id)
 
887
 
920
888
        for n in node.xmlGetChildNodeList('translation'):
921
889
            n.xmlSetData(dir, valcoor)
922
 
        self._updateBatchScriptFile('COMMAND_PERIO')
923
 
 
924
 
 
925
 
    def getRotationDirection(self, perio_name):
 
890
 
 
891
 
 
892
    def getRotationDirection(self, perio_id):
926
893
        """
927
894
        Get values for director vector rotation for periodic translation
928
895
        """
929
 
        self.isInList(perio_name, self.getPeriodicityListName())
 
896
        node = self._getPerioNode(perio_id)
930
897
 
931
 
        node = self.node_perio.xmlGetNode('transformation', name=perio_name)
932
 
        n = node.xmlGetChildNode('rotation1')
933
 
        rx = n.xmlGetString('rotation_x')
934
 
        ry = n.xmlGetString('rotation_y')
935
 
        rz = n.xmlGetString('rotation_z')
 
898
        n = node.xmlGetChildNode('rotation')
 
899
        rx = n.xmlGetString('axis_x')
 
900
        ry = n.xmlGetString('axis_y')
 
901
        rz = n.xmlGetString('axis_z')
936
902
 
937
903
        return rx, ry, rz
938
904
 
939
905
 
940
 
    def setRotationVector(self, perio_name, dir, valcoor):
 
906
    def setRotationVector(self, perio_id, dir, valcoor):
941
907
        """
942
908
        Put values for director vector rotation for periodic translation
943
909
        """
944
910
        self.isFloat(valcoor)
945
 
        self.isInList(perio_name, self.getPeriodicityListName())
946
 
        self.isInList(dir, ("rotation_x", "rotation_y", "rotation_z"))
947
 
 
948
 
        node = self.node_perio.xmlGetNode('transformation', name=perio_name)
949
 
        n = node.xmlGetChildNode('rotation1')
 
911
        self.isInList(dir, ("axis_x", "axis_y", "axis_z"))
 
912
 
 
913
        node = self._getPerioNode(perio_id)
 
914
 
 
915
        n = node.xmlGetChildNode('rotation')
950
916
        n.xmlSetData(dir,valcoor)
951
 
        self._updateBatchScriptFile('COMMAND_PERIO')
952
 
 
953
 
 
954
 
    def getRotationAngle(self, perio_name):
 
917
 
 
918
 
 
919
    def getRotationAngle(self, perio_id):
955
920
        """
956
921
        Get angle for rotation for periodic rotation
957
922
        """
958
 
        self.isInList(perio_name, self.getPeriodicityListName())
 
923
        node = self._getPerioNode(perio_id)
959
924
 
960
 
        node = self.node_perio.xmlGetNode('transformation', name=perio_name)
961
 
        n = node.xmlGetChildNode('rotation1')
962
 
        angle = n.xmlGetString('rotation_angle')
 
925
        n = node.xmlGetChildNode('rotation')
 
926
        angle = n.xmlGetString('angle')
963
927
 
964
928
        return angle
965
929
 
966
930
 
967
 
    def setRotationAngle(self, perio_name, angle):
 
931
    def setRotationAngle(self, perio_id, angle):
968
932
        """
969
933
        Put angle for rotation for periodic rotation
970
934
        """
971
935
        self.isGreaterOrEqual(angle, 0.0)
972
 
        self.isInList(perio_name, self.getPeriodicityListName())
973
 
        node = self.node_perio.xmlGetNode('transformation', name=perio_name)
974
 
        n = node.xmlGetChildNode('rotation1')
975
 
        n.xmlSetData('rotation_angle', angle)
976
 
        self._updateBatchScriptFile('COMMAND_PERIO')
977
 
 
978
 
 
979
 
    def getRotationCenter(self, perio_name):
 
936
 
 
937
        node = self._getPerioNode(perio_id)
 
938
 
 
939
        n = node.xmlGetChildNode('rotation')
 
940
        n.xmlSetData('angle', angle)
 
941
 
 
942
 
 
943
    def getRotationCenter(self, perio_id):
980
944
        """
981
945
        Get coordinates of center of rotation for periodic transformation
982
946
        """
983
 
        self.isInList(perio_name, self.getPeriodicityListName())
984
 
        mode = self.getPeriodicityMode(perio_name)
985
 
        self.isInList(mode, ('rotation1', 'rotation2', 'tr+rota1', 'tr+rota2'))
986
 
 
987
 
        node = self.node_perio.xmlGetNode('transformation', name=perio_name)
988
 
 
989
 
        if mode == "rotation1" or mode == "tr+rota1":
990
 
            n = node.xmlGetChildNode('rotation1')
991
 
        elif mode == "rotation2" or mode == "tr+rota2":
992
 
            n = node.xmlGetChildNode('rotation2')
993
 
        px = n.xmlGetString('rotation_center_x')
994
 
        py = n.xmlGetString('rotation_center_y')
995
 
        pz = n.xmlGetString('rotation_center_z')
 
947
        mode = self.getPeriodicityMode(perio_id)
 
948
        self.isInList(mode, ('rotation'))
 
949
 
 
950
        node = self._getPerioNode(perio_id)
 
951
 
 
952
        if mode == "rotation":
 
953
            n = node.xmlGetChildNode('rotation')
 
954
        px = n.xmlGetString('invariant_x')
 
955
        py = n.xmlGetString('invariant_y')
 
956
        pz = n.xmlGetString('invariant_z')
996
957
 
997
958
        return px, py, pz
998
959
 
999
960
 
1000
 
    def setRotationCenter(self, perio_name, pos, val):
 
961
    def setRotationCenter(self, perio_id, pos, val):
1001
962
        """
1002
963
        Put coordinates of center of rotation for periodic transformation
1003
964
        """
1004
 
        self.isInList(perio_name, self.getPeriodicityListName())
1005
965
        self.isFloat(val)
1006
 
        self.isInList(pos, ("rotation_center_x", "rotation_center_y", "rotation_center_z"))
1007
 
        mode = self.getPeriodicityMode(perio_name)
1008
 
        self.isInList(mode, ('rotation1', 'rotation2', 'tr+rota1', 'tr+rota2'))
1009
 
 
1010
 
        node = self.node_perio.xmlGetNode('transformation', name=perio_name)
1011
 
 
1012
 
        if mode == "rotation1" or mode == "tr+rota1":
1013
 
            n = node.xmlGetChildNode('rotation1')
1014
 
        elif mode == "rotation2" or mode == "tr+rota2":
1015
 
            n = node.xmlGetChildNode('rotation2')
 
966
        self.isInList(pos, ('invariant_x', 'invariant_y', 'invariant_z'))
 
967
        mode = self.getPeriodicityMode(perio_id)
 
968
        self.isInList(mode, ('rotation'))
 
969
 
 
970
        node = self._getPerioNode(perio_id)
 
971
 
 
972
        if mode == 'rotation':
 
973
            n = node.xmlGetChildNode('rotation')
1016
974
        n.xmlSetData(pos, val)
1017
 
        self._updateBatchScriptFile('COMMAND_PERIO')
1018
 
 
1019
 
 
1020
 
    def getRotationMatrix(self, perio_name):
 
975
 
 
976
 
 
977
    def getTransformationMatrix(self, perio_id):
1021
978
        """
1022
979
        Get values of matrix of rotation for periodic transformation
1023
980
        """
1024
 
        self.isInList(perio_name, self.getPeriodicityListName())
1025
 
        mode = self.getPeriodicityMode(perio_name)
1026
 
        self.isInList(mode, ('rotation2', 'tr+rota2'))
1027
 
 
1028
 
        node = self.node_perio.xmlGetNode('transformation', name=perio_name)
1029
 
        n = node.xmlGetChildNode('rotation2')
1030
 
        m11 = n.xmlGetString('rotation_matrix_11')
1031
 
        m12 = n.xmlGetString('rotation_matrix_12')
1032
 
        m13 = n.xmlGetString('rotation_matrix_13')
1033
 
        m21 = n.xmlGetString('rotation_matrix_21')
1034
 
        m22 = n.xmlGetString('rotation_matrix_22')
1035
 
        m23 = n.xmlGetString('rotation_matrix_23')
1036
 
        m31 = n.xmlGetString('rotation_matrix_31')
1037
 
        m32 = n.xmlGetString('rotation_matrix_32')
1038
 
        m33 = n.xmlGetString('rotation_matrix_33')
1039
 
 
1040
 
        return m11, m12, m13, m21, m22, m23, m31, m32, m33
1041
 
 
1042
 
 
1043
 
    def setRotationMatrix(self, perio_name, pos, val):
 
981
        mode = self.getPeriodicityMode(perio_id)
 
982
        self.isInList(mode, ('mixed'))
 
983
 
 
984
        node = self._getPerioNode(perio_id)
 
985
 
 
986
        n = node.xmlGetChildNode('mixed')
 
987
        m11 = n.xmlGetString('matrix_11')
 
988
        m12 = n.xmlGetString('matrix_12')
 
989
        m13 = n.xmlGetString('matrix_13')
 
990
        m14 = n.xmlGetString('matrix_14')
 
991
        m21 = n.xmlGetString('matrix_21')
 
992
        m22 = n.xmlGetString('matrix_22')
 
993
        m23 = n.xmlGetString('matrix_23')
 
994
        m24 = n.xmlGetString('matrix_24')
 
995
        m31 = n.xmlGetString('matrix_31')
 
996
        m32 = n.xmlGetString('matrix_32')
 
997
        m33 = n.xmlGetString('matrix_33')
 
998
        m34 = n.xmlGetString('matrix_34')
 
999
 
 
1000
        return m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34
 
1001
 
 
1002
 
 
1003
    def setTransformationMatrix(self, perio_id, pos, val):
1044
1004
        """
1045
1005
        Put values of matrix of rotation for periodic transformation
1046
1006
        """
1047
 
        self.isInList(perio_name, self.getPeriodicityListName())
1048
1007
        self.isFloat(val)
1049
 
        self.isInList(pos, ('rotation_matrix_11','rotation_matrix_12','rotation_matrix_13',
1050
 
                            'rotation_matrix_21','rotation_matrix_22','rotation_matrix_23',
1051
 
                            'rotation_matrix_31','rotation_matrix_32','rotation_matrix_33'))
1052
 
        mode = self.getPeriodicityMode(perio_name)
1053
 
        self.isInList(mode, ('rotation2', 'tr+rota2'))
1054
 
 
1055
 
        node = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
1056
 
        n = node.xmlGetChildNode('rotation2')
 
1008
        self.isInList(pos, ('matrix_11','matrix_12', 'matrix_13','matrix_14',
 
1009
                            'matrix_21','matrix_22', 'matrix_23','matrix_24',
 
1010
                            'matrix_31','matrix_32', 'matrix_33','matrix_34'))
 
1011
        mode = self.getPeriodicityMode(perio_id)
 
1012
        self.isInList(mode, ('mixed'))
 
1013
 
 
1014
        node = self._getPerioNode(perio_id)
 
1015
 
 
1016
        n = node.xmlGetChildNode('mixed')
1057
1017
        n.xmlSetData(pos, val)
1058
 
        self._updateBatchScriptFile('COMMAND_PERIO')
 
1018
 
 
1019
 
 
1020
    def addPeriodicFaces(self, select):
 
1021
        """
 
1022
        Add faces selection for periodic transformation.
 
1023
        Select is a dictionary with 'selector', 'fraction', 'plane', 'verbosity', 'visualization'
 
1024
        """
 
1025
        nb = self.getPeriodicSelectionsCount()
 
1026
        name = str(nb +1)
 
1027
        node = self.node_perio.xmlAddChild('face_periodicity', mode="", name=name)
 
1028
        self._addJoinSelect(node, select)
 
1029
        self.updatePeriodicityMode(nb, 'translation')
 
1030
 
 
1031
 
 
1032
    def getPeriodicFaces(self, perio_id):
 
1033
        """
 
1034
        Public method.
 
1035
 
 
1036
        @return: faces selection for given periodic transformation
 
1037
        @rtype: C{dictionary}
 
1038
        """
 
1039
        result = {}
 
1040
 
 
1041
        node = self._getPerioNode(perio_id)
 
1042
        if node:
 
1043
            result = self._getFaces(node)
 
1044
 
 
1045
        return result
 
1046
 
 
1047
 
 
1048
    def replacePeriodicFaces(self, perio_id, select):
 
1049
        """
 
1050
        Replace values of faces selection for periodic transformation, by select
 
1051
        """
 
1052
 
 
1053
        node = self._getPerioNode(perio_id)
 
1054
 
 
1055
        if node:
 
1056
            self._removeJoinChildren(node)
 
1057
            self._addJoinSelect(node, select)
1059
1058
 
1060
1059
 
1061
1060
# Methods to manage faces :
1062
1061
#========================
1063
1062
 
 
1063
    def getJoinSelectionsCount(self):
 
1064
        """
 
1065
        Public method.
 
1066
 
 
1067
        @return: number of join faces selections
 
1068
        @rtype: C{int}
 
1069
        """
 
1070
        return len(self.node_join.xmlGetNodeList('face_joining'))
 
1071
 
 
1072
 
1064
1073
    def addJoinFaces(self, select):
1065
1074
        """
1066
 
        Add faces selection for join meshes.
1067
 
        Select is a dictionary with 'color', 'group', 'fraction', 'plan'
 
1075
        Add faces selection for face joining.
 
1076
        Select is a dictionary with 'selector', 'fraction', 'plane', 'verbosity', 'visualization'
1068
1077
        """
1069
 
        nb = self.getJoinSelectionsNumber()
 
1078
        nb = self.getJoinSelectionsCount()
1070
1079
        name = str(nb +1)
1071
 
        node = self.node_join.xmlAddChild('faces_join', status="on", name=name)
1072
 
        self._addFacesSelect(node, select)
1073
 
        self._updateBatchScriptFile('COMMAND_JOIN')
1074
 
 
1075
 
 
1076
 
    def getJoinFaces(self, number):
1077
 
        """
1078
 
        Return faces selection named 'number' for join meshes .
1079
 
        """
1080
 
        self.isLowerOrEqual(int(number), int(self.getJoinSelectionsNumber()))
1081
 
 
1082
 
        node = self.node_join.xmlGetNode('faces_join', status="on", name=number)
 
1080
        node = self.node_join.xmlAddChild('face_joining', name=name)
 
1081
        self._addJoinSelect(node, select)
 
1082
 
 
1083
 
 
1084
    def getJoinFaces(self, join_id):
 
1085
        """
 
1086
        Return faces selection named 'number' for face joining .
 
1087
        """
 
1088
        node = self._getJoinNode(join_id)
1083
1089
        return self._getFaces(node)
1084
1090
 
1085
1091
 
1086
 
    def replaceJoinFaces(self, number, select):
1087
 
        """
1088
 
        Replace values of faces selection named 'number' for join meshes, by select
1089
 
        """
1090
 
        self.isLowerOrEqual(int(number), int(self.getJoinSelectionsNumber()))
1091
 
 
1092
 
        node = self.node_join.xmlGetNode('faces_join', status="on", name=number)
1093
 
        self._removeChildren(node)
1094
 
        self._addFacesSelect(node, select)
1095
 
        self._updateBatchScriptFile('COMMAND_JOIN')
1096
 
 
1097
 
 
1098
 
    def deleteJoinFaces(self, number):
1099
 
        """
1100
 
        Delete faces selection named 'number' for join meshes
1101
 
        """
1102
 
        self.isLowerOrEqual(int(number), int(self.getJoinSelectionsNumber()))
1103
 
 
1104
 
        node = self.node_join.xmlGetNode('faces_join', status="on", name=number)
1105
 
        node.xmlRemoveNode()
1106
 
        if int(number) <= int(self.getJoinSelectionsNumber()):
1107
 
            self._updateJoinSelectionsNumbers()
1108
 
        self._updateBatchScriptFile('COMMAND_JOIN')
1109
 
 
1110
 
 
1111
 
    def setJoinStatus(self, number, status):
1112
 
        """
1113
 
        Set status of faces selection named 'number' for join meshes
1114
 
        """
1115
 
        self.isOnOff(status)
1116
 
        self.isLowerOrEqual(int(number), int(self.getJoinSelectionsNumber()))
1117
 
 
1118
 
        node = self.node_join.xmlGetNode('faces_join', 'status', name=number)
1119
 
        node['status'] = status
1120
 
 
1121
 
 
1122
 
    def getJoinStatus(self, number):
1123
 
        """
1124
 
        Get status of faces selection named 'number' for join meshes
1125
 
        """
1126
 
        self.isLowerOrEqual(int(number), int(self.getJoinSelectionsNumber()))
1127
 
 
1128
 
        return self.node_join.xmlGetNode('faces_join', 'status', name=number)['status']
1129
 
 
1130
 
 
1131
 
    def addPeriodicFaces(self, perio_name, select):
1132
 
        """
1133
 
        Add faces selection for periodic transformation.
1134
 
        Select is a dictionary with 'color', 'group', 'fraction', 'plan' ...
1135
 
        """
1136
 
        self.isInList(perio_name, self.getPeriodicityListName())
1137
 
        node_tr = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
1138
 
        if node_tr:
1139
 
            node = node_tr.xmlAddChild('faces_periodic', status="on")
1140
 
            self._addFacesSelect(node, select)
1141
 
            self._updateBatchScriptFile('COMMAND_PERIO')
1142
 
 
1143
 
 
1144
 
    def getPeriodicFaces(self, perio_name):
1145
 
        """
1146
 
        Public method.
1147
 
 
1148
 
        @return: faces selection for periodic transformation named perio_name
1149
 
        @rtype: C{dictionary}
1150
 
        """
1151
 
        self.isInList(perio_name, self.getPeriodicityListName())
1152
 
        result = {}
1153
 
        node_tr = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
1154
 
        if node_tr:
1155
 
            node = node_tr.xmlGetChildNode('faces_periodic', 'status')
1156
 
            if node and node['status'] == 'on':
1157
 
                result = self._getFaces(node)
1158
 
 
1159
 
        return result
1160
 
 
1161
 
 
1162
 
    def replacePeriodicFaces(self, perio_name, select):
1163
 
        """
1164
 
        Replace values of faces selection for periodic transformation, by select
1165
 
        """
1166
 
        self.isInList(perio_name, self.getPeriodicityListName())
1167
 
        node_tr = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
1168
 
        if node_tr:
1169
 
            node = node_tr.xmlGetChildNode('faces_periodic', status="on")
1170
 
            self._removeChildren(node)
1171
 
            self._addFacesSelect(node, select)
1172
 
            self._updateBatchScriptFile('COMMAND_PERIO')
1173
 
 
1174
 
 
1175
 
    def deletePeriodicFaces(self, perio_name):
1176
 
        """
1177
 
        Delete faces selection for periodic transformation named 'perio_name'
1178
 
        """
1179
 
        self.isInList(perio_name, self.getPeriodicityListName())
1180
 
        node_tr = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
1181
 
        if node_tr:
1182
 
            node = node_tr.xmlGetChildNode('faces_periodic', status="on")
1183
 
            node.xmlRemoveNode()
1184
 
            self._updateBatchScriptFile('COMMAND_PERIO')
1185
 
 
1186
 
 
1187
 
    def setPeriodicStatus(self, perio_name, status):
1188
 
        """
1189
 
        Set status of faces for periodic transformation named 'perio_name'
1190
 
        """
1191
 
        self.isOnOff(status)
1192
 
        node_tr = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
1193
 
        if node_tr:
1194
 
            node = node_tr.xmlGetChildNode('faces_periodic', 'status')
1195
 
            if node:
1196
 
                node['status'] = status
1197
 
            if status == 'on':
1198
 
                self._updateBatchScriptFile('COMMAND_PERIO')
1199
 
 
1200
 
 
1201
 
    def getPeriodicStatus(self, perio_name):
1202
 
        """
1203
 
        Get status of faces for periodic transformation named 'perio_name'
1204
 
        """
1205
 
        node_tr = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
1206
 
        if node_tr:
1207
 
            node = node_tr.xmlGetChildNode('faces_periodic', 'status')
1208
 
            if node:
1209
 
                status = node['status']
1210
 
            return status
1211
 
        else:
1212
 
            raise ValueError, "wrong periodicity"
1213
 
 
1214
 
 
1215
 
    def addSelectFaces(self, select):
1216
 
        """
1217
 
        Add faces selection for standalone selection.
1218
 
        Select is a dictionary with 'color', 'group', 'fraction', 'plan' ...
1219
 
        """
1220
 
        node = self.node_standalone.xmlGetChildNode('faces_select', 'status')
1221
 
        if node:
1222
 
            node['status'] = "on"
1223
 
        else:
1224
 
            node = self.node_standalone.xmlAddChild('faces_select', status="on")
1225
 
        select['fraction'] =""
1226
 
        select['plan'] = ""
1227
 
        select['semiconf'] = ""
1228
 
        self._addFacesSelect(node, select)
1229
 
 
1230
 
 
1231
 
    def getSelectFaces(self):
1232
 
        """
1233
 
        Return faces selection for standalone selection (only one authorized selection)
1234
 
        """
1235
 
        result = {}
1236
 
        node  = self.node_standalone.xmlGetChildNode('faces_select', status="on")
1237
 
        if node:
1238
 
            result = self._getFaces(node)
1239
 
 
1240
 
        return result
1241
 
 
1242
 
 
1243
 
    def replaceSelectFaces(self, select):
1244
 
        """
1245
 
        Replace values of faces selection for standalone selection (only one authorized selection)
1246
 
        by select
1247
 
        """
1248
 
        node  = self.node_standalone.xmlGetChildNode('faces_select', status="on")
1249
 
        self._removeChildren(node)
1250
 
        select['fraction'] =""
1251
 
        select['plan'] = ""
1252
 
        select['semiconf'] = ""
1253
 
        self._addFacesSelect(node, select)
1254
 
 
1255
 
 
1256
 
    def deleteSelectFaces(self):
1257
 
        """
1258
 
        Delete faces selection for standalone selection (only one authorized selection)
1259
 
        """
1260
 
        node = self.node_standalone.xmlGetChildNode('faces_select', 'status')
1261
 
        node.xmlRemoveNode()
1262
 
 
1263
 
 
1264
 
    def setSelectStatus(self, status):
1265
 
        """
1266
 
        Set status of faces selection for standalone selection (only one authorized selection)
1267
 
        """
1268
 
        self.isOnOff(status)
1269
 
        node = self.node_standalone.xmlInitNode('faces_select', 'status')
1270
 
        if status == "off":
1271
 
            self.deleteSelectFaces()
1272
 
        else:
1273
 
            node['status'] = status
1274
 
 
1275
 
 
1276
 
    def getSelectStatus(self):
1277
 
        """
1278
 
        Get status of faces selection for standalone selection (only one authorized selection)
1279
 
        """
1280
 
        node = self.node_standalone.xmlInitChildNode('faces_select', 'status')
1281
 
        status = node['status']
1282
 
        if not status:
1283
 
            status = self.defaultValues()['select_status']
1284
 
            self.deleteSelectFaces()
1285
 
 
1286
 
        return status
1287
 
 
1288
 
 
1289
 
# In following methods we build command for "lance" file
1290
 
#=======================================================
 
1092
    def replaceJoinFaces(self, join_id, select):
 
1093
        """
 
1094
        Replace values of faces selection named 'number' for face joining, by select
 
1095
        """
 
1096
        node = self._getJoinNode(join_id)
 
1097
        self._removeJoinChildren(node)
 
1098
        self._addJoinSelect(node, select)
 
1099
 
 
1100
 
 
1101
    def deleteJoinFaces(self, join_id):
 
1102
        """
 
1103
        Delete faces selection named 'number' for face joining
 
1104
        """
 
1105
        node = self._getJoinNode(join_id)
 
1106
        node.xmlRemoveNode()
 
1107
        if join_id < self.getJoinSelectionsCount():
 
1108
            self._updateJoinSelectionNumbers()
 
1109
 
 
1110
 
 
1111
# In following methods we build the command to run the Preprocessor
 
1112
#==================================================================
1291
1113
 
1292
1114
    def getMeshCommand(self):
1293
1115
        """
1299
1121
        for meshNode in nodeList:
1300
1122
            name   = meshNode['name']
1301
1123
            format = meshNode['format']
1302
 
            #f = string.split(string.split(name,".")[1]," ")[0]
1303
 
            #if f not in .getExtensionFileList():
1304
 
            #         name=string.split(name," ")[0]
1305
1124
            mesh = self.case['mesh_path'] + '/' + name
1306
1125
            lines += " -m " + mesh
1307
1126
 
 
1127
            if meshNode['format']:
 
1128
                lines += " --format " + meshNode['format']
1308
1129
            if meshNode['num']:
1309
1130
                lines += " --num " + meshNode['num']
1310
1131
            if meshNode['grp_fac']:
1311
1132
                lines += " --grp-fac " + meshNode['grp_fac']
1312
1133
            if meshNode['grp_cel']:
1313
1134
                lines += " --grp-cel " + meshNode['grp_cel']
 
1135
            if meshNode['reorient']:
 
1136
                lines += " --reorient"
1314
1137
 
1315
1138
        lines += " "
1316
1139
        return lines
1317
1140
 
1318
1141
 
1319
 
    def getReorientCommand(self):
1320
 
        """
1321
 
        Get reorient command line for preprocessor execution
1322
 
        """
1323
 
        line = ''
1324
 
        if self.node_orient and self.node_orient['status'] == 'on':
1325
 
            line += ' --reorient '
1326
 
 
1327
 
        return line
1328
 
 
1329
 
 
1330
 
    def getJoinCommand(self):
1331
 
        """
1332
 
        Get rc command line for preprocessor execution
1333
 
        """
1334
 
        lines = ''
1335
 
        if self.node_join and self.node_join['status'] == 'on':
1336
 
            node_face_join_list = self.node_join.xmlGetNodeList('faces_join')
1337
 
            if node_face_join_list:
1338
 
                for node_face_join in node_face_join_list:
1339
 
                    if node_face_join['status'] == 'on':
1340
 
                        linecoul = ' -j '
1341
 
                        line = self._getLineCommand(node_face_join)
1342
 
                        lines = lines + linecoul + line
1343
 
 
1344
 
                        fraction = node_face_join.xmlGetString('faces_fraction')
1345
 
                        lines = lines + " --fraction " + fraction +" "
1346
 
                        plan = node_face_join.xmlGetString('faces_plan')
1347
 
                        lines = lines + " --plane " + plan +" "
1348
 
                        lines = lines + ' '
1349
 
            else:
1350
 
                lines = ' -j '
1351
 
 
1352
 
        return lines
1353
 
 
1354
 
 
1355
 
    def getCutCommand(self):
1356
 
        """
1357
 
        Get cwf command line for preprocessor execution
1358
 
        """
1359
 
        line = ''
1360
 
        if self.node_cut and self.node_cut['status'] == 'on':
1361
 
            line += ' --cwf ' + str(self.getCutAngle())
1362
 
 
1363
 
        return line
1364
 
 
1365
 
 
1366
 
    def getPerioCommand(self):
1367
 
        """
1368
 
        Get perio command line for preprocessor execution
1369
 
        """
1370
 
        line   = ''
1371
 
        for perio_name in self.getPeriodicityListName():
1372
 
            node = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
1373
 
            mode = self.getPeriodicityMode(perio_name)
1374
 
            node_face_perio = node.xmlGetNode('faces_periodic', 'status')
1375
 
            if node_face_perio:
1376
 
                node_face_perio_list = node.xmlGetNodeList('faces_periodic', 'status')
1377
 
                if node_face_perio_list:
1378
 
                    for node in node_face_perio_list:
1379
 
                        if node['status'] == 'on':
1380
 
                            lineperio = ' --perio '
1381
 
                            l = self._getLineCommand(node)
1382
 
                            line = line + lineperio + l
1383
 
                            fraction = node.xmlGetString('faces_fraction')
1384
 
                            if fraction:
1385
 
                                line = line + " --fraction " + fraction +" "
1386
 
                            plan = node.xmlGetString('faces_plan')
1387
 
                            if plan:
1388
 
                                line = line + " --plane " + plan +" "
1389
 
            else:
1390
 
                line = line + ' --perio '
1391
 
            mode = self.getPeriodicityMode(perio_name)
1392
 
            if mode == 'translation' or mode == 'tr+rota1' or mode == 'tr+rota2':
1393
 
                dx, dy, dz = self.getTranslationDirection(perio_name)
1394
 
                line = line + " --trans " + dx +" " + dy +" " + dz +" "
1395
 
            if mode == 'rotation1' or mode == 'tr+rota1':
1396
 
                angle = self.getRotationAngle(perio_name)
1397
 
                rx, ry, rz = self.getRotationDirection(perio_name)
1398
 
                px, py, pz = self.getRotationCenter(perio_name)
1399
 
                line = line + " --rota "  + " --angle " + angle + " --dir " + rx +" " + ry +" " + rz +" " + " --invpt " + px +" " + py +" " + pz +" "
1400
 
            if mode == 'rotation2' or mode == 'tr+rota2':
1401
 
                m11, m12, m13, m21, m22, m23, m31, m32, m33 = self.getRotationMatrix(perio_name)
1402
 
                px, py, pz = self.getRotationCenter(perio_name)
1403
 
                line = line + " --rota "  + " --matrix " + m11 +" " + m12 +" " + m13 +" " + m21 +" " + m22 +" " + m23 +" " + m31 +" " + m32 +" " + m33 +" " + " --invpt " + px +" " + py +" " + pz +" "
1404
 
 
1405
 
        return line
1406
 
 
1407
 
 
1408
1142
    def getSimCommCommand(self):
1409
1143
        """
1410
 
        Get " --sim-comm " command line for preprocessor execution
 
1144
        Get " --no-write " command line for preprocessor execution
1411
1145
        """
1412
1146
        lines = ''
1413
1147
        node = self.node_standalone.xmlGetNode('simulation_communication')
1414
1148
        if node and node['status'] == 'on':
1415
 
            lines = " -sc "
1416
 
        return lines
1417
 
 
1418
 
 
1419
 
    def getSelectCommand(self):
1420
 
        """
1421
 
        Get "--int-face" command line for preprocessor execution
1422
 
        """
1423
 
        lines  = ''
1424
 
        node_list = self.node_standalone.xmlGetNodeList('faces_select')
1425
 
        for nod in node_list:
1426
 
            if nod['status'] == 'on':
1427
 
                line = ' --int-face ' + self._getLineCommand(nod)
1428
 
                lines += line
 
1149
            lines = " --no-write "
1429
1150
        return lines
1430
1151
 
1431
1152
 
1437
1158
        iok = 0
1438
1159
        if self.getPostProFormat() == "EnSight":
1439
1160
            line = ' --ensight '
1440
 
        if self.getPostProFormat() == "MED_fichier":
 
1161
        if self.getPostProFormat() == "MED":
1441
1162
            line = ' --med '
1442
1163
        if self.getPostProFormat() == "CGNS":
1443
1164
            line = ' --cgns '
1444
1165
 
1445
 
        options = self.getPostProOptionsFormat()
1446
 
        options = string.split(options, ',')
1447
 
 
1448
 
        for opt in options:
1449
 
            if opt in ('binary', 'discard_polygons', 'discard_polyhedra'):
1450
 
                line = line
1451
 
            if opt in ('divide_polygons', 'divide_polyhedra'):
1452
 
                opt = line + ' --divide-poly '
1453
 
            if opt == "big_endian":
1454
 
                line = line + ' --big_endian '
1455
 
 
1456
1166
        return line
1457
1167
 
1458
1168
 
1459
 
# These following methods are kept only for tkInter View
1460
 
#=======================================================
1461
 
 
1462
 
    def getListNodes(self, tagName):
1463
 
        """
1464
 
        Return node corresponding at the selection (only for view)
1465
 
        """
1466
 
        node = self._getTagNode(tagName)
1467
 
        listNode = node.xmlGetNodeList(tagName)
1468
 
 
1469
 
        return listNode
1470
 
 
1471
 
 
1472
 
    def getStatusNode(self, node):
1473
 
        """
1474
 
        Return status for node "node"
1475
 
        """
1476
 
        if node : status = node['status']
1477
 
        return status
1478
 
 
1479
 
 
1480
 
    def getFacesSelect(self, tagName, n):
1481
 
        """
1482
 
        Return default filled with values found for color, group ..
1483
 
        """
1484
 
        nodeList = self.getListNodes(tagName)
1485
 
        node = nodeList[n]
1486
 
        return self._getFaces(node)
1487
 
 
1488
 
 
1489
1169
#-------------------------------------------------------------------------------
1490
1170
# SolutionDomain Model test case
1491
1171
#-------------------------------------------------------------------------------
1500
1180
        assert model != None, 'Could not instantiate SolutionDomainModel'
1501
1181
 
1502
1182
    def checkAddDelMeshandGetMeshList(self):
1503
 
        """ Check whether the meshes could be added and deleted and list of meshes could be get """
 
1183
        """ Check whether the meshes could be added and deleted and list of meshes could be got """
1504
1184
        mdl = SolutionDomainModel(self.case)
1505
1185
        mdl.addMesh('fdc','des')
1506
1186
        mdl.addMesh('pic','des')
1519
1199
            'Could not get mesh list'
1520
1200
 
1521
1201
 
1522
 
    def checkSetandGetJoinMeshesStatus(self):
1523
 
        """ Check whether the status of join meshes could be set and get"""
1524
 
        mdl = SolutionDomainModel(self.case)
1525
 
        mdl.setJoinMeshesStatus('on')
1526
 
        doc = '''<join_meshes status="on"/>'''
1527
 
        assert mdl.node_join == self.xmlNodeFromString(doc), \
1528
 
            'Could not set status in join meshes balise'
1529
 
        assert mdl.getJoinMeshesStatus() == 'on', \
1530
 
            'Could not get status from join meshes balise'
1531
 
 
1532
1202
    def checkSetandGetCutStatusAndAngleValue(self):
1533
 
        """ Check whether the status of node cut and value of angle could be set and get"""
 
1203
        """ Check whether the status of node cut and value of angle could be set and got"""
1534
1204
        mdl = SolutionDomainModel(self.case)
1535
1205
        mdl.setCutStatus('on')
1536
1206
        doc1 = '''<faces_cutting status="on"/>'''
1551
1221
            'Could not get angle for faces_cutting'
1552
1222
 
1553
1223
    def checkSetandGetSimCommStatus(self):
1554
 
        """ Check whether the status of node simulation_communication could be set and get"""
 
1224
        """ Check whether the status of node simulation_communication could be set and got"""
1555
1225
        mdl = SolutionDomainModel(self.case)
1556
1226
        mdl.setSimCommStatus('on')
1557
1227
        doc = '''<standalone>
1563
1233
        assert mdl.getSimCommStatus() == 'on', \
1564
1234
            'Could not get status of node simulation_communication'
1565
1235
 
1566
 
    def checkGetPeriodicityNumber(self):
1567
 
        """ Check whether the number of periodicities could be get"""
 
1236
    def checkgetPeriodicSelectionsCount(self):
 
1237
        """ Check whether the number of periodicities could be got"""
 
1238
        select = {}
 
1239
        select['selector'] = '1 or 2 or 3 or toto'
 
1240
        select['fraction'] = '0.1'
 
1241
        select['plane'] = '20'
 
1242
        select['verbosity'] = 1
 
1243
        select['visualization'] = 1
1568
1244
        mdl = SolutionDomainModel(self.case)
1569
 
        mdl.addPeriodicity('1')
1570
 
        mdl.addPeriodicity('2')
1571
 
        doc ='''<periodic_boundary>
1572
 
                    <transformation mode="translation" name="1">
1573
 
                        <translation>
1574
 
                            <translation_x>0</translation_x>
1575
 
                            <translation_y>0</translation_y>
1576
 
                            <translation_z>0</translation_z>
1577
 
                        </translation>
1578
 
                    </transformation>
1579
 
                    <transformation mode="translation" name="2">
1580
 
                        <translation>
1581
 
                            <translation_x>0</translation_x>
1582
 
                            <translation_y>0</translation_y>
1583
 
                            <translation_z>0</translation_z>
1584
 
                        </translation>
1585
 
                    </transformation>
1586
 
                 </periodic_boundary>'''
 
1245
        mdl.addPeriodicFaces(select)
 
1246
        mdl.addPeriodicFaces(select)
 
1247
        doc ='''<face_periodicity mode="translation" name="1">
 
1248
                      <translation>
 
1249
                            <translation_x>0</translation_x>
 
1250
                            <translation_y>0</translation_y>
 
1251
                            <translation_z>0</translation_z>
 
1252
                      </translation>
 
1253
                </face_periodicity>
 
1254
                <face_periodicity mode="translation" name="2">
 
1255
                      <translation>
 
1256
                            <translation_x>0</translation_x>
 
1257
                            <translation_y>0</translation_y>
 
1258
                            <translation_z>0</translation_z>
 
1259
                        </translation>
 
1260
                </face_periodicity>'''
1587
1261
 
1588
1262
        assert mdl.node_perio == self.xmlNodeFromString(doc),\
1589
1263
            'Could not set number of periodicities'
1590
 
        assert mdl.getPeriodicityNumber() == 2,\
 
1264
        assert mdl.getPeriodicSelectionsCount() == 2,\
1591
1265
            'Could not get number for periodicities'
1592
1266
 
1593
1267
    def checkSetandgetPeriodicityMode(self):
1594
 
        """ Check whether the mode of transformation could be set and get """
 
1268
        """ Check whether the mode of transformation could be set and got """
 
1269
        select = {}
 
1270
        select['selector'] = '1 or 2 or 3 or toto'
 
1271
        select['fraction'] = '0.1'
 
1272
        select['plane'] = '20'
 
1273
        select['verbosity'] = 1
 
1274
        select['visualization'] = 1
1595
1275
        mdl = SolutionDomainModel(self.case)
1596
 
        mdl.addPeriodicity('1')
1597
 
        mdl.addPeriodicity('2')
1598
 
        mdl.updatePeriodicityMode('2', "tr+rota1")
1599
 
        doc ='''<periodic_boundary>
1600
 
                    <transformation mode="translation" name="1">
1601
 
                        <translation>
1602
 
                            <translation_x>0</translation_x>
1603
 
                            <translation_y>0</translation_y>
1604
 
                            <translation_z>0</translation_z>
1605
 
                        </translation>
1606
 
                    </transformation>
1607
 
                    <transformation mode="tr+rota1" name="2">
1608
 
                        <translation>
1609
 
                            <translation_x>0</translation_x>
1610
 
                            <translation_y>0</translation_y>
1611
 
                            <translation_z>0</translation_z>
1612
 
                        </translation>
1613
 
                        <rotation1>
1614
 
                            <rotation_angle>0</rotation_angle>
1615
 
                            <rotation_x>0</rotation_x>
1616
 
                            <rotation_y>0</rotation_y>
1617
 
                            <rotation_z>0</rotation_z>
1618
 
                            <rotation_center_x>0</rotation_center_x>
1619
 
                            <rotation_center_y>0</rotation_center_y>
1620
 
                            <rotation_center_z>0</rotation_center_z>
1621
 
                        </rotation1>
1622
 
                    </transformation>
1623
 
            </periodic_boundary>'''
 
1276
        mdl.addPeriodicFaces(select)
 
1277
        mdl.addPeriodicFaces(select)
 
1278
        mdl.updatePeriodicityMode('2', "rotation")
 
1279
        doc ='''<face_periodicity mode="translation" name="1">
 
1280
                      <translation>
 
1281
                            <translation_x>0</translation_x>
 
1282
                            <translation_y>0</translation_y>
 
1283
                            <translation_z>0</translation_z>
 
1284
                      </translation>
 
1285
                </face_periodicity mode="rotation" name="2">
 
1286
                      <translation>
 
1287
                            <translation_x>0</translation_x>
 
1288
                            <translation_y>0</translation_y>
 
1289
                            <translation_z>0</translation_z>
 
1290
                      </translation>
 
1291
                      <rotation>
 
1292
                            <angle>0</angle>
 
1293
                            <axis_x>0</axis_x>
 
1294
                            <axis_y>0</axis_y>
 
1295
                            <axis_z>0</axis_z>
 
1296
                            <invariant_x>0</invariant_x>
 
1297
                            <invariant_y>0</invariant_y>
 
1298
                            <invariant_z>0</invariant_z>
 
1299
                      </rotation>
 
1300
                </face_periodicity>'''
1624
1301
 
1625
1302
 
1626
1303
        assert mdl.node_perio == self.xmlNodeFromString(doc),\
1627
1304
            'Could not set mode of transformation for periodicities'
1628
 
        assert mdl.getPeriodicityMode('2') == "tr+rota1",\
 
1305
        assert mdl.getPeriodicityMode('2') == "rotation",\
1629
1306
            'Could not get mode of transformation for periodicities'
1630
1307
 
1631
1308
    def checkSetandgetTranslationDirection(self):
1632
 
        """ Check whether the dir values translation mode of periodicity could be set and get"""
 
1309
        """ Check whether the dir values translation mode of periodicity could be set and got"""
 
1310
        select = {}
 
1311
        select['selector'] = '1 or 2 or 3 or toto'
 
1312
        select['fraction'] = '0.1'
 
1313
        select['plane'] = '20'
 
1314
        select['verbosity'] = 1
 
1315
        select['visualization'] = 1
1633
1316
        mdl = SolutionDomainModel(self.case)
1634
 
        mdl.addPeriodicity('1')
 
1317
        mdl.addPeriodicFaces(select)
1635
1318
        mdl.setTranslationDirection('1','translation_y',3.0)
1636
 
        doc ='''<periodic_boundary>
1637
 
                    <transformation mode="translation" name="1">
1638
 
                            <translation>
1639
 
                                    <translation_x>0</translation_x>
1640
 
                                    <translation_y>3</translation_y>
1641
 
                                    <translation_z>0</translation_z>
1642
 
                            </translation>
1643
 
                    </transformation>
1644
 
                </periodic_boundary>'''
 
1319
        doc ='''<face_periodicity mode="translation" name="1">
 
1320
                      <translation>
 
1321
                            <translation_x>0</translation_x>
 
1322
                            <translation_y>3</translation_y>
 
1323
                            <translation_z>0</translation_z>
 
1324
                      </translation>
 
1325
                </face_periodicity>'''
1645
1326
 
1646
1327
        assert mdl.node_perio == self.xmlNodeFromString(doc),\
1647
1328
            'Could not set one direction values for translation'
1649
1330
            'Could not get one direction values for translation'
1650
1331
 
1651
1332
    def checkSetandgetRotationDirectionandAngleandCenter(self):
1652
 
        """ Check whether the values for rotation's mode of periodicity could be set and get"""
 
1333
        """ Check whether the values for rotation's mode of periodicity could be set and got"""
 
1334
        select = {}
 
1335
        select['selector'] = '1 or 2 or 3 or toto'
 
1336
        select['fraction'] = '0.1'
 
1337
        select['plane'] = '20'
 
1338
        select['verbosity'] = 1
 
1339
        select['visualization'] = 1
1653
1340
        mdl = SolutionDomainModel(self.case)
1654
 
        mdl.addPeriodicity('1')
 
1341
        mdl.addPeriodicFaces(select)
1655
1342
        mdl.setTranslationDirection('1','translation_y', 3.0)
1656
 
        mdl.addPeriodicity('2')
1657
 
        mdl.updatePeriodicityMode('2', "tr+rota1")
 
1343
        mdl.addPeriodicFaces(select)
 
1344
        mdl.updatePeriodicityMode('2', "rotation")
1658
1345
        mdl.setRotationAngle('2', 180.)
1659
 
        mdl.setRotationVector('2', 'rotation_x', 0.5)
1660
 
        mdl.setRotationVector('2', 'rotation_z', 2.5)
1661
 
        mdl.setRotationCenter('2', 'rotation_center_y', 9.8)
1662
 
        doc ='''<periodic_boundary>
1663
 
                    <transformation mode="translation" name="1">
1664
 
                            <translation>
1665
 
                                    <translation_x>0</translation_x>
1666
 
                                    <translation_y>3</translation_y>
1667
 
                                    <translation_z>0</translation_z>
1668
 
                            </translation>
1669
 
                    </transformation>
1670
 
                    <transformation mode="tr+rota1" name="2">
1671
 
                            <translation>
1672
 
                                    <translation_x>0</translation_x>
1673
 
                                    <translation_y>0</translation_y>
1674
 
                                    <translation_z>0</translation_z>
1675
 
                            </translation>
1676
 
                            <rotation1>
1677
 
                                    <rotation_angle>180</rotation_angle>
1678
 
                                    <rotation_x>0.5</rotation_x>
1679
 
                                    <rotation_y>0.0</rotation_y>
1680
 
                                    <rotation_z>2.5</rotation_z>
1681
 
                                    <rotation_center_x>0</rotation_center_x>
1682
 
                                    <rotation_center_y>9.8</rotation_center_y>
1683
 
                                    <rotation_center_z>0</rotation_center_z>
1684
 
                            </rotation1>
1685
 
                    </transformation>
1686
 
                </periodic_boundary>'''
 
1346
        mdl.setRotationVector('2', 'axis_x', 0.5)
 
1347
        mdl.setRotationVector('2', 'axis_z', 2.5)
 
1348
        mdl.setRotationCenter('2', 'invariant_y', 9.8)
 
1349
        doc ='''<face_periodicity mode="translation" name="1">
 
1350
                      <translation>
 
1351
                            <translation_x>0</translation_x>
 
1352
                            <translation_y>3</translation_y>
 
1353
                            <translation_z>0</translation_z>
 
1354
                      </translation>
 
1355
                </face_periodicity>
 
1356
                <face_periodicity mode="rotation" name="2">
 
1357
                      <translation>
 
1358
                            <translation_x>0</translation_x>
 
1359
                            <translation_y>0</translation_y>
 
1360
                            <translation_z>0</translation_z>
 
1361
                      </translation>
 
1362
                      <rotation>
 
1363
                            <angle>180</angle>
 
1364
                            <axis_x>0.5</axis_x>
 
1365
                            <axis_y>0.0</axis_y>
 
1366
                            <axis_z>2.5</axis_z>
 
1367
                            <invariant_x>0</invariant_x>
 
1368
                            <invariant_y>9.8</invariant_y>
 
1369
                            <invariant_z>0</invariant_z>
 
1370
                      </rotation>
 
1371
                </face_periodicity>'''
1687
1372
 
1688
1373
        assert mdl.node_perio == self.xmlNodeFromString(doc),\
1689
1374
            'Could not set values for rotation transformation mode'
1694
1379
        assert mdl.getRotationCenter('2') == ('0', '9.8', '0'),\
1695
1380
            'Could not get value of center of rotation for rotation transformation mode'
1696
1381
 
1697
 
    def checkSetandgetRotationMatrix(self):
1698
 
        """ Check whether the matrix of rotation for rotation2 mode could be set """
 
1382
    def checkSetandgetTransformationMatrix(self):
 
1383
        """ Check whether the matrix of rotation for mixed mode could be set """
 
1384
        select = {}
 
1385
        select['selector'] = '1 or 2 or 3 or toto'
 
1386
        select['fraction'] = '0.1'
 
1387
        select['plane'] = '20'
 
1388
        select['verbosity'] = 1
 
1389
        select['visualization'] = 1
1699
1390
        mdl = SolutionDomainModel(self.case)
1700
 
        mdl.addPeriodicity('1')
1701
 
        mdl.updatePeriodicityMode('1','rotation2')
1702
 
        mdl.setRotationMatrix('1', 'rotation_matrix_31', 31.31)
1703
 
        doc = '''<periodic_boundary>
1704
 
                    <transformation mode="rotation2" name="1">
1705
 
                            <translation>
1706
 
                                    <translation_x>0.0</translation_x>
1707
 
                                    <translation_y>0.0</translation_y>
1708
 
                                    <translation_z>0.0</translation_z>
1709
 
                            </translation>
1710
 
                            <rotation2>
1711
 
                                    <rotation_matrix_11>0.0</rotation_matrix_11>
1712
 
                                    <rotation_matrix_12>0.0</rotation_matrix_12>
1713
 
                                    <rotation_matrix_13>0.0</rotation_matrix_13>
1714
 
                                    <rotation_matrix_21>0.0</rotation_matrix_21>
1715
 
                                    <rotation_matrix_22>0.0</rotation_matrix_22>
1716
 
                                    <rotation_matrix_23>0.0</rotation_matrix_23>
1717
 
                                    <rotation_matrix_31>31.31</rotation_matrix_31>
1718
 
                                    <rotation_matrix_32>0.0</rotation_matrix_32>
1719
 
                                    <rotation_matrix_33>0.0</rotation_matrix_33>
1720
 
                                    <rotation_center_y>0.0</rotation_center_y>
1721
 
                                    <rotation_center_z>0.0</rotation_center_z>
1722
 
                            </rotation2>
1723
 
                    </transformation>
1724
 
                 </periodic_boundary>'''
 
1391
        mdl.addPeriodicFaces(select)
 
1392
        mdl.updatePeriodicityMode('1','mixed')
 
1393
        mdl.setTransformationMatrix('1', 'matrix_31', 31.31)
 
1394
        doc = '''<face_periodicity mode="mixed" name="1">
 
1395
                      <mixed>
 
1396
                            <matrix_11>0.0</matrix_11>
 
1397
                            <matrix_12>0.0</matrix_12>
 
1398
                            <matrix_13>0.0</matrix_13>
 
1399
                            <matrix_14>0.0</matrix_14>
 
1400
                            <matrix_21>0.0</matrix_21>
 
1401
                            <matrix_22>0.0</matrix_22>
 
1402
                            <matrix_23>0.0</matrix_23>
 
1403
                            <matrix_24>0.0</matrix_24>
 
1404
                            <matrix_31>31.31</matrix_31>
 
1405
                            <matrix_32>0.0</matrix_32>
 
1406
                            <matrix_33>0.0</matrix_33>
 
1407
                            <matrix_34>0.0</matrix_34>
 
1408
                      </mixed>
 
1409
                 </face_periodicity>'''
1725
1410
 
1726
1411
        assert mdl.node_perio == self.xmlNodeFromString(doc),\
1727
 
            'Could not set values for matrix of rotation for rotation2 transformation mode'
1728
 
        assert mdl.getRotationMatrix('1') == ('0', '0', '0', '0', '0', '0', '31.31','0', '0'),\
1729
 
            'Could not get values for matrix of rotation for rotation2 transformation mode'
 
1412
            'Could not set values for matrix of rotation for mixed transformation mode'
 
1413
        assert mdl.getTransformationMatrix('1') == ('0', '0', '0', '0',
 
1414
                                                    '0', '0', '0', '0',
 
1415
                                                    '31.31','0', '0', '0'),\
 
1416
            'Could not get values for matrix of rotation for mixed transformation mode'
1730
1417
 
1731
1418
    def checkAddandGetJoinFaces(self):
1732
 
        """ Check whether faces of join meshes could be added and get """
 
1419
        """ Check whether faces of face joining could be added and get """
1733
1420
        select = {}
1734
 
        select['color'] = '1 2 3'
1735
 
        select['group'] = 'toto'
 
1421
        select['selector'] = '1 or 2 or 3 or toto'
1736
1422
        select['fraction'] = '0.1'
1737
 
        select['plan'] = '0.8'
1738
 
        select['reverse'] = 'off'
1739
 
        select['semiconf'] = 'on'
 
1423
        select['plane'] = '20'
 
1424
        select['verbosity'] = 1
 
1425
        select['visualization'] = 1
1740
1426
        mdl = SolutionDomainModel(self.case)
1741
 
        mdl.setJoinMeshesStatus('on')
1742
1427
        mdl.addJoinFaces(select)
1743
 
        doc = '''<join_meshes status="on">
1744
 
                    <faces_join name="1" status="on">
1745
 
                            <faces_color>1 2 3</faces_color>
1746
 
                            <faces_group>toto</faces_group>
1747
 
                            <faces_fraction>0.1</faces_fraction>
1748
 
                            <faces_plan>0.8</faces_plan>
1749
 
                            <faces_semi_conf status="on"/>
1750
 
                    </faces_join>
1751
 
                 </join_meshes>'''
 
1428
        doc = '''<face_joining name="1">
 
1429
                    <selector>1 or 2 or 3 or toto</selector>
 
1430
                    <fraction>0.1</fraction>
 
1431
                    <plane>20</plane>
 
1432
                    <verbosity>1</verbosity>
 
1433
                    <visualization>1</visualization>
 
1434
                 </face_joining>'''
1752
1435
 
1753
1436
        assert mdl.node_join == self.xmlNodeFromString(doc),\
1754
 
            'Could not set values of faces join for join meshes'
1755
 
        assert mdl.getJoinFaces('1') == {'semiconf': 'on', 'reverse': 'off',
1756
 
                                         'color': '1 2 3', 'plan': '0.8',
1757
 
                                         'fraction': '0.1', 'group': 'toto'},\
1758
 
            'Could not get values of faces join for join meshes'
 
1437
            'Could not set values of faces join for face joining'
 
1438
        assert mdl.getJoinFaces('1') == {'selector': '1 or 2 or 3 or toto', 'plane': '20',
 
1439
                                         'fraction': '0.1', 'verbosity': '1',
 
1440
                                         'visualization': '1'},\
 
1441
            'Could not get values of faces join for face joining'
1759
1442
 
1760
 
    def checkReplaceandDeleteandSetandGetStatusForJoinFaces(self):
 
1443
    def checkReplaceandDeleteandSetandGetForJoinFaces(self):
1761
1444
        """
1762
 
        Check whether faces of join meshes could be replaced and deleted
1763
 
        and status could be set and get
 
1445
        Check whether faces of face joining could be replaced and deleted
 
1446
        and status could be set and got
1764
1447
        """
1765
1448
        select = {}
1766
 
        select['color'] = '1 2 3'
1767
 
        select['group'] = 'toto'
 
1449
        select['selector'] = '1 or 2 or 3 or toto'
1768
1450
        select['fraction'] = '0.1'
1769
 
        select['plan'] = '0.8'
1770
 
        select['reverse'] = 'off'
1771
 
        select['semiconf'] = 'on'
 
1451
        select['plane'] = '20'
 
1452
        select['verbosity'] = '1'
 
1453
        select['visualization'] = '1'
1772
1454
        deux = {}
1773
 
        deux['color'] = '9 8 7'
1774
 
        deux['group'] = 'coucou'
 
1455
        deux['selector'] = '9 or 8 or 7 or coucou'
1775
1456
        deux['fraction'] = '0.2'
1776
 
        deux['plan'] = '0.82'
1777
 
        deux['reverse'] = 'off'
1778
 
        deux['semiconf'] = 'off'
 
1457
        deux['plane'] = '20'
 
1458
        deux['verbosity'] = '2'
 
1459
        deux['visualization'] = '2'
1779
1460
        mdl = SolutionDomainModel(self.case)
1780
 
        mdl.setJoinMeshesStatus('on')
1781
1461
        mdl.addJoinFaces(select)
1782
1462
        mdl.addJoinFaces(deux)
1783
 
        doc = '''<join_meshes status="on">
1784
 
                    <faces_join name="1" status="on">
1785
 
                            <faces_color>1 2 3</faces_color>
1786
 
                            <faces_group>toto</faces_group>
1787
 
                            <faces_fraction>0.1</faces_fraction>
1788
 
                            <faces_plan>0.8</faces_plan>
1789
 
                            <faces_semi_conf status="on"/>
1790
 
                    </faces_join>
1791
 
                    <faces_join name="2" status="on">
1792
 
                            <faces_color>9 8 7</faces_color>
1793
 
                            <faces_group>coucou</faces_group>
1794
 
                            <faces_fraction>0.2</faces_fraction>
1795
 
                            <faces_plan>0.82</faces_plan>
1796
 
                    </faces_join>
1797
 
                 </join_meshes>'''
 
1463
        doc = '''<joining>
 
1464
                    <face_joining name="1">
 
1465
                            <selector>1 or 2 or 3 or toto</selector>
 
1466
                            <fraction>0.1</fraction>
 
1467
                            <plane>20</plane>
 
1468
                            <verbosity>1</verbosity>
 
1469
                            <visualization>1</visualization>
 
1470
                    </face_joining>
 
1471
                    <face_joining name="2">
 
1472
                            <selector>9 or 8 or 7 or coucou</selector>
 
1473
                            <fraction>0.2</fraction>
 
1474
                            <plane>30</plane>
 
1475
                            <verbosity>2</verbosity>
 
1476
                            <visualization>2</visualization>
 
1477
                    </face_joining>
 
1478
                 </joining>'''
1798
1479
 
1799
1480
        assert mdl.node_join == self.xmlNodeFromString(doc),\
1800
 
            'Could not set values of faces join for join meshes'
1801
 
        assert mdl.getJoinFaces('1') == {'group': 'toto', 'reverse': 'off', 'color': '1 2 3',
1802
 
                                        'plan': '0.8', 'fraction': '0.1',
1803
 
                                        'semiconf': 'on'},\
1804
 
            'Could not get values of faces join for join meshes'
 
1481
            'Could not set values of faces join for face joining'
 
1482
        assert mdl.getJoinFaces('1') == {'selector': '1 or 2 or 3 or toto',
 
1483
                                        'plane': '20', 'fraction': '0.1',
 
1484
                                        'verbosity': '1', 'visualization': '1'},\
 
1485
            'Could not get values of faces join for face joining'
1805
1486
 
1806
 
        select['group'] = 'je vais partir'
 
1487
        select['selector'] = 'je vais partir'
1807
1488
        mdl.replaceJoinFaces('1', select)
1808
 
        doc = '''<join_meshes status="on">
1809
 
                    <faces_join name="1" status="on">
1810
 
                            <faces_color>1 2 3</faces_color>
1811
 
                            <faces_group>je vais partir</faces_group>
1812
 
                            <faces_fraction>0.1</faces_fraction>
1813
 
                            <faces_plan>0.8</faces_plan>
1814
 
                            <faces_semi_conf status="on"/>
1815
 
                    </faces_join>
1816
 
                    <faces_join name="2" status="on">
1817
 
                            <faces_color>9 8 7</faces_color>
1818
 
                            <faces_group>coucou</faces_group>
1819
 
                            <faces_fraction>0.2</faces_fraction>
1820
 
                            <faces_plan>0.82</faces_plan>
1821
 
                    </faces_join>
1822
 
                 </join_meshes>'''
 
1489
        doc = '''<joining>
 
1490
                    <face_joining name="1">
 
1491
                            <selector>1 or 2 or 3 or toto</selector>
 
1492
                            <fraction>0.1</fraction>
 
1493
                            <plane>20</plane>
 
1494
                            <verbosity>1</verbosity>
 
1495
                            <visualization>1</visualization>
 
1496
                    </face_joining>
 
1497
                    <face_joining name="2">
 
1498
                            <selector>9 or 8 or 7 or coucou</selector>
 
1499
                            <fraction>0.2</fraction>
 
1500
                            <plane>30</plane>
 
1501
                            <verbosity>2</verbosity>
 
1502
                            <visualization>2</visualization>
 
1503
                    </face_joining>
 
1504
                 </joining>'''
1823
1505
 
1824
1506
        assert mdl.node_join == self.xmlNodeFromString(doc),\
1825
 
            'Could not replace values of faces join for join meshes'
 
1507
            'Could not replace values of faces join for face joining'
1826
1508
 
1827
1509
        mdl.deleteJoinFaces('1')
1828
 
        doc = '''<join_meshes status="on">
1829
 
                    <faces_join name="1" status="on">
1830
 
                            <faces_color>9 8 7</faces_color>
1831
 
                            <faces_group>coucou</faces_group>
1832
 
                            <faces_fraction>0.2</faces_fraction>
1833
 
                            <faces_plan>0.82</faces_plan>
1834
 
                    </faces_join>
1835
 
                 </join_meshes>'''
 
1510
        doc = '''<joining>
 
1511
                    <face_joining name="1">
 
1512
                            <selector>9 or 8 or 7 or coucou</selector>
 
1513
                            <fraction>0.2</fraction>
 
1514
                            <plane>30</plane>
 
1515
                            <verbosity>2</verbosity>
 
1516
                            <visualization>2</visualization>
 
1517
                    </face_joining>
 
1518
                 </joining>'''
1836
1519
 
1837
1520
        assert mdl.node_join == self.xmlNodeFromString(doc),\
1838
 
            'Could not delete faces join for join meshes'
 
1521
            'Could not delete faces join for face joining'
1839
1522
 
1840
1523
        mdl.addJoinFaces(select)
1841
 
        mdl.setJoinStatus('1', 'off')
1842
 
        doc = '''<join_meshes status="on">
1843
 
                    <faces_join name="1" status="off">
1844
 
                            <faces_color>9 8 7</faces_color>
1845
 
                            <faces_group>coucou</faces_group>
1846
 
                            <faces_fraction>0.2</faces_fraction>
1847
 
                            <faces_plan>0.82</faces_plan>
1848
 
                    </faces_join>
1849
 
                    <faces_join name="2" status="on">
1850
 
                            <faces_color>1 2 3</faces_color>
1851
 
                            <faces_group>je vais partir</faces_group>
1852
 
                            <faces_fraction>0.1</faces_fraction>
1853
 
                            <faces_plan>0.8</faces_plan>
1854
 
                            <faces_semi_conf status="on"/>
1855
 
                    </faces_join>
1856
 
                 </join_meshes>'''
 
1524
        doc = '''<joining>
 
1525
                    <face_joining name="1">
 
1526
                            <selector>9 or 8 or 7 or coucou</selector>
 
1527
                            <fraction>0.2</fraction>
 
1528
                            <plane>30</plane>
 
1529
                            <verbosity>2</verbosity>
 
1530
                            <visualization>2</visualization>
 
1531
                    </face_joining>
 
1532
                    <face_joining name="2">
 
1533
                            <selector>1 or 2 or 3 or toto</selector>
 
1534
                            <fraction>0.1</fraction>
 
1535
                            <plane>20</plane>
 
1536
                            <verbosity>1</verbosity>
 
1537
                            <visualization>1</visualization>
 
1538
                    </face_joining>
 
1539
                 </joining>'''
1857
1540
 
1858
1541
        assert mdl.node_join == self.xmlNodeFromString(doc),\
1859
 
            'Could not set status for active or not faces join for join meshes'
1860
 
        assert mdl.getJoinStatus('1') == 'off',\
1861
 
            'Could not get status for active or not faces join for join meshes'
 
1542
            'Could not set faces join for joinings'
1862
1543
 
1863
1544
    def checkAddandGetPeriodicFaces(self):
1864
1545
        """ Check whether faces of periodicity could be added and get """
1865
1546
        select = {}
1866
 
        select['color'] = '5 6'
1867
 
        select['group'] = 'toto'
 
1547
        select['selector'] = '5 or 6 or toto'
1868
1548
        select['fraction'] = '0.1'
1869
 
        select['plan'] = '0.8'
1870
 
        select['reverse'] = 'off'
1871
 
        select['semiconf'] = 'off'
 
1549
        select['plane'] = '20'
 
1550
        select['verbosity'] = '2'
 
1551
        select['visualization'] = '2'
1872
1552
        mdl = SolutionDomainModel(self.case)
1873
 
        mdl.addPeriodicity('1')
1874
 
        mdl.addPeriodicity('2')
1875
 
        mdl.updatePeriodicityMode('2', 'rotation1')
1876
 
        mdl.addPeriodicFaces('1', select)
1877
 
        mdl.addPeriodicFaces('2', select)
1878
 
        doc = '''<periodic_boundary>
1879
 
                    <transformation mode="translation" name="1">
1880
 
                        <translation>
1881
 
                            <translation_x>0</translation_x>
1882
 
                            <translation_y>0</translation_y>
1883
 
                            <translation_z>0</translation_z>
1884
 
                        </translation>
1885
 
                        <faces_periodic status="on">
1886
 
                            <faces_color>5 6</faces_color>
1887
 
                            <faces_group>toto</faces_group>
1888
 
                            <faces_fraction>0.1</faces_fraction>
1889
 
                            <faces_plan>0.8</faces_plan>
1890
 
                        </faces_periodic>
1891
 
                    </transformation>
1892
 
                    <transformation mode="rotation1" name="2">
1893
 
                        <translation>
1894
 
                            <translation_x>0</translation_x>
1895
 
                            <translation_y>0</translation_y>
1896
 
                            <translation_z>0</translation_z>
1897
 
                        </translation>
1898
 
                        <rotation1>
1899
 
                            <rotation_angle>0</rotation_angle>
1900
 
                            <rotation_x>0</rotation_x>
1901
 
                            <rotation_y>0</rotation_y>
1902
 
                            <rotation_z>0</rotation_z>
1903
 
                            <rotation_center_x>0</rotation_center_x>
1904
 
                            <rotation_center_y>0</rotation_center_y>
1905
 
                            <rotation_center_z>0</rotation_center_z>
1906
 
                        </rotation1>
1907
 
                        <faces_periodic status="on">
1908
 
                            <faces_color>5 6</faces_color>
1909
 
                            <faces_group>toto</faces_group>
1910
 
                            <faces_fraction>0.1</faces_fraction>
1911
 
                            <faces_plan>0.8</faces_plan>
1912
 
                        </faces_periodic>
1913
 
                    </transformation>
1914
 
                 </periodic_boundary>'''
 
1553
        mdl.addPeriodicFaces(select)
 
1554
        mdl.addPeriodicFaces(select)
 
1555
        mdl.updatePeriodicityMode('2', 'rotation')
 
1556
        doc = '''<face_periodicity>
 
1557
                 <face_periodicity mode="translation" name="1">
 
1558
                        <selector>5 or 6 or toto</selector>
 
1559
                        <fraction>0.1</fraction>
 
1560
                        <plane>0.8</plane>
 
1561
                        <translation>
 
1562
                            <translation_x>0</translation_x>
 
1563
                            <translation_y>0</translation_y>
 
1564
                            <translation_z>0</translation_z>
 
1565
                        </translation>
 
1566
                 </face_periodicity>
 
1567
                 <face_periodicity mode="rotation" name="2">
 
1568
                        <translation>
 
1569
                            <translation_x>0</translation_x>
 
1570
                            <translation_y>0</translation_y>
 
1571
                            <translation_z>0</translation_z>
 
1572
                        </translation>
 
1573
                        <rotation>
 
1574
                            <angle>0</angle>
 
1575
                            <axis_x>0</axis_x>
 
1576
                            <axis_y>0</axis_y>
 
1577
                            <axis_z>0</axis_z>
 
1578
                            <invariant_x>0</invariant_x>
 
1579
                            <invariant_y>0</invariant_y>
 
1580
                            <invariant_z>0</invariant_z>
 
1581
                        </rotation>
 
1582
                        <face_periodicity status="on">
 
1583
                            <selector>5 or 6 or toto</selector>
 
1584
                            <fraction>0.1</fraction>
 
1585
                            <plane>0.8</plane>
 
1586
                        </face_periodicity>
 
1587
                 </face_periodicity>'''
1915
1588
        assert mdl.node_perio == self.xmlNodeFromString(doc),\
1916
1589
            'Could not add values of faces for periodicities'
1917
 
        assert mdl.getPeriodicFaces('1') == {'group': 'toto', 'reverse': 'off', 'color': '5 6',
1918
 
                                        'plan': '0.8', 'fraction': '0.1', 'semiconf': 'off'},\
 
1590
        assert mdl.getPeriodicFaces('1') == {'selector': '5 or 6 or toto',
 
1591
                                             'plane': '30', 'fraction': '0.1',
 
1592
                                             'verbosity': '2', 'visualization': '2'},\
1919
1593
            'Could not get values of faces for periodicities'
1920
1594
 
1921
1595
    def checkReplaceandDeleteandSetandGetStatusForPeriodicFaces(self):
1922
1596
        """
1923
1597
        Check whether faces of of periodicity could be replaced and deleted
1924
 
        and status could be set and get
 
1598
        and status could be set and got
1925
1599
        """
1926
1600
        select = {}
1927
 
        select['color'] = '5 6'
1928
 
        select['group'] = 'toto'
 
1601
        select['selector'] = '5 or 6 or toto'
1929
1602
        select['fraction'] = '0.1'
1930
 
        select['plan'] = '0.8'
1931
 
        select['reverse'] = 'off'
1932
 
        select['semiconf'] = 'off'
 
1603
        select['plane'] = '25'
 
1604
        select['verbosity'] = '1'
 
1605
        select['visualization'] = '1'
1933
1606
        mdl = SolutionDomainModel(self.case)
1934
 
        mdl.addPeriodicity('1')
1935
 
        mdl.addPeriodicity('2')
1936
 
        mdl.updatePeriodicityMode('2', 'rotation1')
1937
 
        mdl.addPeriodicFaces('1', select)
1938
 
        mdl.addPeriodicFaces('2', select)
1939
 
        mdl.deletePeriodicFaces('2')
1940
 
        doc = '''<periodic_boundary>
1941
 
                    <transformation mode="translation" name="1">
1942
 
                            <translation>
1943
 
                                    <translation_x>0.0</translation_x>
1944
 
                                    <translation_y>0.0</translation_y>
1945
 
                                    <translation_z>0.0</translation_z>
1946
 
                            </translation>
1947
 
                            <faces_periodic status="on">
1948
 
                                    <faces_color>5 6</faces_color>
1949
 
                                    <faces_group>toto</faces_group>
1950
 
                                    <faces_fraction>0.1</faces_fraction>
1951
 
                                    <faces_plan>0.8</faces_plan>
1952
 
                            </faces_periodic>
1953
 
                    </transformation>
1954
 
                    <transformation mode="rotation1" name="2">
1955
 
                            <translation>
1956
 
                                    <translation_x>0.0</translation_x>
1957
 
                                    <translation_y>0.0</translation_y>
1958
 
                                    <translation_z>0.0</translation_z>
1959
 
                            </translation>
1960
 
                            <rotation1>
1961
 
                                    <rotation_angle>0.0</rotation_angle>
1962
 
                                    <rotation_x>0.0</rotation_x>
1963
 
                                    <rotation_y>0.0</rotation_y>
1964
 
                                    <rotation_z>0.0</rotation_z>
1965
 
                                    <rotation_center_x>0.0</rotation_center_x>
1966
 
                                    <rotation_center_y>0.0</rotation_center_y>
1967
 
                                    <rotation_center_z>0.0</rotation_center_z>
1968
 
                            </rotation1>
1969
 
                    </transformation>
1970
 
                 </periodic_boundary>'''
 
1607
        mdl.addPeriodicFaces(select)
 
1608
        mdl.addPeriodicFaces(select)
 
1609
        mdl.updatePeriodicityMode('2', 'rotation')
 
1610
        doc = '''<face_periodicity mode="translation" name="1">
 
1611
                       <translation>
 
1612
                            <translation_x>0.0</translation_x>
 
1613
                            <translation_y>0.0</translation_y>
 
1614
                            <translation_z>0.0</translation_z>
 
1615
                       </translation>
 
1616
                       <selector>5 or 6 or toto</selector>
 
1617
                       <fraction>0.1</fraction>
 
1618
                       <plane>25</plane>
 
1619
                       <verbosity>1</verbosity>
 
1620
                       <visualization>1</visualization>
 
1621
                 </face_periodicity>
 
1622
                 <face_periodic mode="rotation" name="2">
 
1623
                       <translation>
 
1624
                            <translation_x>0.0</translation_x>
 
1625
                            <translation_y>0.0</translation_y>
 
1626
                            <translation_z>0.0</translation_z>
 
1627
                       </translation>
 
1628
                       <rotation>
 
1629
                            <angle>0.0</angle>
 
1630
                            <axis_x>0.0</axis_x>
 
1631
                            <axis_y>0.0</axis_y>
 
1632
                            <axis_z>0.0</axis_z>
 
1633
                            <invariant_x>0.0</invariant_x>
 
1634
                            <invariant_y>0.0</invariant_y>
 
1635
                            <invariant_z>0.0</invariant_z>
 
1636
                       </rotation>
 
1637
                 </face_periodicity>'''
1971
1638
 
1972
1639
        assert mdl.node_perio == self.xmlNodeFromString(doc),\
1973
1640
            'Could not delete one selection of faces for periodicities'
1974
1641
 
1975
 
        select['color'] = '147 963'
1976
 
        select['group'] = 'PERIODIC'
 
1642
        select['selector'] = '147 or 963 or PERIODIC'
1977
1643
        select['fraction'] = '0.1'
1978
 
        select['plan']  = '0.77'
1979
 
        select['reverse'] = 'off'
1980
 
        select['semiconf'] = 'off'
 
1644
        select['plane']  = '20'
 
1645
        select['verbosity'] = '2'
 
1646
        select['visualization'] = '2'
1981
1647
        mdl.replacePeriodicFaces('1', select)
1982
 
        doc = '''<periodic_boundary>
1983
 
                    <transformation mode="translation" name="1">
1984
 
                            <translation>
1985
 
                                    <translation_x>0.0</translation_x>
1986
 
                                    <translation_y>0.0</translation_y>
1987
 
                                    <translation_z>0.0</translation_z>
1988
 
                            </translation>
1989
 
                            <faces_periodic status="on">
1990
 
                                    <faces_color>147 963</faces_color>
1991
 
                                    <faces_group>PERIODIC</faces_group>
1992
 
                                    <faces_fraction>0.1</faces_fraction>
1993
 
                                    <faces_plan>0.77</faces_plan>
1994
 
                            </faces_periodic>
1995
 
                    </transformation>
1996
 
                    <transformation mode="rotation1" name="2">
1997
 
                            <translation>
1998
 
                                    <translation_x>0.0</translation_x>
1999
 
                                    <translation_y>0.0</translation_y>
2000
 
                                    <translation_z>0.0</translation_z>
2001
 
                            </translation>
2002
 
                            <rotation1>
2003
 
                                    <rotation_angle>0.0</rotation_angle>
2004
 
                                    <rotation_x>0.0</rotation_x>
2005
 
                                    <rotation_y>0.0</rotation_y>
2006
 
                                    <rotation_z>0.0</rotation_z>
2007
 
                                    <rotation_center_x>0.0</rotation_center_x>
2008
 
                                    <rotation_center_y>0.0</rotation_center_y>
2009
 
                                    <rotation_center_z>0.0</rotation_center_z>
2010
 
                            </rotation1>
2011
 
                    </transformation>
2012
 
                 </periodic_boundary>'''
 
1648
        doc = '''<face_periodicity mode="translation" name="1">
 
1649
                     <translation>
 
1650
                            <translation_x>0.0</translation_x>
 
1651
                            <translation_y>0.0</translation_y>
 
1652
                            <translation_z>0.0</translation_z>
 
1653
                     </translation>
 
1654
                     <selector>147 or 963 or PERIODIC</selector>
 
1655
                     <fraction>0.1</fraction>
 
1656
                     <plane>30</plane>
 
1657
                     <verbosity>1</verbosity>
 
1658
                     <visualization>1</visualization>
 
1659
                 </face_periodicity>
 
1660
                 </face_periodicity mode="rotation" name="2">
 
1661
                     <translation>
 
1662
                            <translation_x>0.0</translation_x>
 
1663
                            <translation_y>0.0</translation_y>
 
1664
                            <translation_z>0.0</translation_z>
 
1665
                     </translation>
 
1666
                     <rotation>
 
1667
                            <angle>0.0</angle>
 
1668
                            <axis_x>0.0</axis_x>
 
1669
                            <axis_y>0.0</axis_y>
 
1670
                            <axis_z>0.0</axis_z>
 
1671
                            <invariant_x>0.0</invariant_x>
 
1672
                            <invariant_y>0.0</invariant_y>
 
1673
                            <invariant_z>0.0</invariant_z>
 
1674
                     </rotation>
 
1675
                 </face_periodicity>'''
2013
1676
        assert mdl.node_perio == self.xmlNodeFromString(doc),\
2014
1677
            'Could not replace values of faces for periodicities'
2015
1678
 
2016
 
        mdl.setPeriodicStatus('1', 'off')
2017
 
        doc = '''<periodic_boundary>
2018
 
                    <transformation mode="translation" name="1">
2019
 
                            <translation>
2020
 
                                    <translation_x>0.0</translation_x>
2021
 
                                    <translation_y>0.0</translation_y>
2022
 
                                    <translation_z>0.0</translation_z>
2023
 
                            </translation>
2024
 
                            <faces_periodic status="off">
2025
 
                                    <faces_color>147 963</faces_color>
2026
 
                                    <faces_group>PERIODIC</faces_group>
2027
 
                                    <faces_fraction>0.1</faces_fraction>
2028
 
                                    <faces_plan>0.77</faces_plan>
2029
 
                            </faces_periodic>
2030
 
                    </transformation>
2031
 
                    <transformation mode="rotation1" name="2">
2032
 
                            <translation>
2033
 
                                    <translation_x>0.0</translation_x>
2034
 
                                    <translation_y>0.0</translation_y>
2035
 
                                    <translation_z>0.0</translation_z>
2036
 
                            </translation>
2037
 
                            <rotation1>
2038
 
                                    <rotation_angle>0.0</rotation_angle>
2039
 
                                    <rotation_x>0.0</rotation_x>
2040
 
                                    <rotation_y>0.0</rotation_y>
2041
 
                                    <rotation_z>0.0</rotation_z>
2042
 
                                    <rotation_center_x>0.0</rotation_center_x>
2043
 
                                    <rotation_center_y>0.0</rotation_center_y>
2044
 
                                    <rotation_center_z>0.0</rotation_center_z>
2045
 
                            </rotation1>
2046
 
                    </transformation>
2047
 
                 </periodic_boundary>'''
 
1679
        doc = '''<face_periodicity mode="translation" name="1">
 
1680
                      <selector>147 or 963 or PERIODIC</selector>
 
1681
                      <fraction>0.1</fraction>
 
1682
                      <plane>30</plane>
 
1683
                      <verbosity>1</verbosity>
 
1684
                      <visualization>1</visualization>
 
1685
                      <translation>
 
1686
                            <translation_x>0.0</translation_x>
 
1687
                            <translation_y>0.0</translation_y>
 
1688
                            <translation_z>0.0</translation_z>
 
1689
                      </translation>
 
1690
                 </face_periodicity>
 
1691
                 <face_periodicity mode="rotation" name="2">
 
1692
                      <translation>
 
1693
                            <translation_x>0.0</translation_x>
 
1694
                            <translation_y>0.0</translation_y>
 
1695
                            <translation_z>0.0</translation_z>
 
1696
                      </translation>
 
1697
                      <rotation>
 
1698
                            <angle>0.0</angle>
 
1699
                            <axis_x>0.0</axis_x>
 
1700
                            <axis_y>0.0</axis_y>
 
1701
                            <axis_z>0.0</axis_z>
 
1702
                            <invariant_x>0.0</invariant_x>
 
1703
                            <invariant_y>0.0</invariant_y>
 
1704
                            <invariant_z>0.0</invariant_z>
 
1705
                     </rotation>
 
1706
                 </face_periodicity>'''
2048
1707
        assert mdl.node_perio == self.xmlNodeFromString(doc),\
2049
 
            'Could not set status for activate or not selection of faces for periodicities'
2050
 
        assert mdl.getPeriodicStatus('1') == 'off',\
2051
 
            'Could not get status for activate or not selection of faces for periodicities'
2052
 
 
2053
 
    def checkAddandGetSelectFaces(self):
2054
 
        """ Check whether faces of standalone could be added and get """
2055
 
        select = {}
2056
 
        select['color'] = '8 2'
2057
 
        select['group'] = 'STAND'
2058
 
        select['reverse'] = 'off'
2059
 
        select['semiconf'] = 'off'
2060
 
        mdl = SolutionDomainModel(self.case)
2061
 
        mdl.addSelectFaces(select)
2062
 
        doc = '''<standalone>
2063
 
                    <faces_select status="on">
2064
 
                            <faces_color>8 2</faces_color>
2065
 
                            <faces_group>STAND</faces_group>
2066
 
                    </faces_select>
2067
 
                 </standalone>'''
2068
 
 
2069
 
        assert mdl.node_standalone == self.xmlNodeFromString(doc),\
2070
 
            'Could not add values of faces for standalone selection'
2071
 
        assert mdl.getSelectFaces() == {'group': 'STAND', 'reverse': 'off', 'color': '8 2',
2072
 
                                        'plan': '', 'fraction': '', 'semiconf': 'off'},\
2073
 
            'Could not get values of faces for standalone selection'
2074
 
 
2075
 
    def checkReplaceandDeleteandSetandGetStatusForSelectFaces(self):
2076
 
        """
2077
 
        Check whether faces of standalone could be replaced and deleted
2078
 
        and status could be set and get
2079
 
        """
2080
 
        select = {}
2081
 
        select['color'] = '8 2'
2082
 
        select['group'] = 'STAND'
2083
 
        select['reverse'] = 'off'
2084
 
        select['semiconf'] = 'off'
2085
 
        mdl = SolutionDomainModel(self.case)
2086
 
        mdl.addSelectFaces(select)
2087
 
        new = {}
2088
 
        new['color'] = '7 8 9'
2089
 
        new['group'] = 'NEW'
2090
 
        new['reverse'] = 'off'
2091
 
        new['semiconf'] = 'off'
2092
 
        mdl.replaceSelectFaces(new)
2093
 
        doc = '''<standalone>
2094
 
                    <faces_select status="on">
2095
 
                        <faces_color>7 8 9</faces_color>
2096
 
                        <faces_group>NEW</faces_group>
2097
 
                    </faces_select>
2098
 
                 </standalone>'''
2099
 
 
2100
 
        assert mdl.node_standalone == self.xmlNodeFromString(doc),\
2101
 
            'Could not replace values of faces for standalone selection'
2102
 
 
2103
 
        mdl.deleteSelectFaces()
2104
 
        doc = '''<standalone/>'''
2105
 
 
2106
 
        assert mdl.node_standalone == self.xmlNodeFromString(doc),\
2107
 
            'Could not delete values of faces for standalone selection'
2108
 
 
2109
 
        select['group'] = 'NOUVEAU'
2110
 
        mdl.addSelectFaces(select)
2111
 
        mdl.setSelectStatus('off')
2112
 
        doc = '''<standalone/>'''
2113
 
 
2114
 
        assert mdl.node_standalone == self.xmlNodeFromString(doc),\
2115
 
            'Could not set status for activate selection of faces for standalone selection'
2116
 
        assert mdl.getSelectStatus() == 'off',\
2117
 
            'Could not get status for activate selection of faces for standalone selection'
 
1708
            'Could not set selection of faces for periodicities'
 
1709
 
2118
1710
 
2119
1711
    def checkMeshCommand(self):
2120
1712
        """ Check whether  command for meshes could be set """
2121
1713
        mdl = SolutionDomainModel(self.case)
2122
1714
        mdl.case['mesh_path'] = 'MESH'
2123
1715
        mdl.addMesh('fdc.des','des')
2124
 
        mdl.addMesh('pic.des','des')
2125
 
        mdl.addMesh('truc.ngeom','ngeom')
2126
 
        line = ''' -m MESH/fdc.des -m MESH/pic.des -m MESH/truc.ngeom '''
 
1716
        line = ''' -m MESH/fdc.des '''
2127
1717
 
2128
1718
        assert mdl.getMeshCommand() == line,\
2129
1719
            'Mesh command is not verified in SolutionDomain Model'
2130
1720
 
2131
1721
 
2132
1722
    def checkReorientSetAndGetStatusAndCommand(self):
2133
 
        """ Check whether reorient status could be set and get and command line could be get """
 
1723
        """ Check whether reorient status could be set and got and command line could be got """
2134
1724
        mdl = SolutionDomainModel(self.case)
2135
1725
        mdl.setOrientation('on')
2136
1726
        doc = '''<reorientation status="on"/>'''
2145
1735
            'Reorient command is not verified in SolutionDomain Model'
2146
1736
 
2147
1737
 
2148
 
    def checkJoinAndCutCommand(self):
2149
 
        """ Check whether join and cut command lines could be get """
2150
 
        mdl = SolutionDomainModel(self.case)
2151
 
        select = {}
2152
 
        select['color'] = '1 2 3'
2153
 
        select['group'] = 'toto'
2154
 
        select['fraction'] = '0.1'
2155
 
        select['plan'] = '0.8'
2156
 
        select['reverse'] = 'off'
2157
 
        select['semiconf'] = 'on'
2158
 
        mdl.setJoinMeshesStatus('on')
2159
 
        mdl.addJoinFaces(select)
2160
 
        cmd_join = ' -j  --color 1 2 3 --group toto --fraction 0.1  --plane 0.8  '
2161
 
 
2162
 
        assert mdl.getJoinCommand() == cmd_join,\
2163
 
            'Join command is not verified in SolutionDomain Model'
2164
 
 
2165
 
        mdl.setCutStatus('on')
2166
 
        mdl.setCutAngle(0.05)
2167
 
        cmd_cut = mdl.getCutCommand()
2168
 
        cut = ' --cwf 0.05'
2169
 
        assert mdl.getCutCommand() == cmd_cut,\
2170
 
            'Cut command is not verified in SolutionDomain Model'
2171
 
 
2172
 
    def checkPerioCommand(self):
2173
 
        """ Check whether perio command line could be get """
2174
 
        mdl = SolutionDomainModel(self.case)
2175
 
        mdl.addPeriodicity('1')
2176
 
        mdl.updatePeriodicityMode('1','rotation1')
2177
 
        mdl.setRotationVector('1', 'rotation_x', 9.)
2178
 
        mdl.setRotationVector('1', 'rotation_y', 8.)
2179
 
        mdl.setRotationVector('1', 'rotation_z', 7.)
2180
 
        mdl.setRotationAngle('1', 45.)
2181
 
        mdl.setRotationCenter('1', 'rotation_center_y', 66.)
2182
 
        mdl.addPeriodicity('2')
2183
 
        mdl.updatePeriodicityMode('2','tr+rota2')
2184
 
        mdl.setTranslationDirection('2','translation_y', 3)
2185
 
        mdl.setRotationMatrix('2', 'rotation_matrix_31', 31.31)
2186
 
        cmd_perio = " --perio  --rota  --angle 45 --dir 9 8 7  --invpt 0 66 0  --perio  --trans 0 3 0  --rota  --matrix 0 0 0 0 0 0 31.31 0 0  --invpt  0 0 "
2187
 
 
2188
 
        assert mdl.getPerioCommand() == cmd_perio,\
2189
 
            'Perio command is not verified in SolutionDomain Model'
2190
 
 
2191
1738
    def checkSimCommAndVerifMaillCommand(self):
2192
 
        """ Check whether simulation_communication command line could be get """
 
1739
        """ Check whether simulation_communication command line could be got """
2193
1740
        mdl = SolutionDomainModel(self.case)
2194
1741
        mdl.setSimCommStatus('on')
2195
1742
        cmd_sim = mdl.getSimCommCommand()
2197
1744
        assert mdl.getSimCommCommand() == sim,\
2198
1745
            'Simulation_communication command is not verified in SolutionDomain Model'
2199
1746
 
2200
 
        #A reprendre :
2201
 
####    def checkSelectCommand(self):
2202
 
####        """Check whether standalone selection command line could be get"""
2203
 
####        select = {}
2204
 
####        select['color'] = '1 2 3'
2205
 
####        select['group'] = 'toto'
2206
 
####        select['reverse'] = 'off'
2207
 
####        select['semiconf'] = 'on'
2208
 
####        mdl = SolutionDomainModel(self.case)
2209
 
####        mdl.addSelectFaces(select)
2210
 
####        print mdl.getSelectCommand()
2211
 
######        --int-face  --color 1 2 3 --group toto
2212
 
####        select =' --color 1 2 3  --group toto  --semi-conf '
2213
 
######        select =' --int-face  --color 1 2 3  --group toto  --semi-conf '
2214
 
####        assert mdl.getSelectCommand().split() == select.split(),\
2215
 
####            'Standalone selection faces command is not verified in SolutionDomain Model'
2216
 
####
2217
1747
    def checkPostCommand(self):
2218
 
        """Check whether output postprocessing format command line could be get"""
 
1748
        """Check whether output postprocessing format command line could be got"""
2219
1749
        mdl = SolutionDomainModel(self.case)
2220
1750
        mdl.setPostProFormat('CGNS')
2221
1751
 
2224
1754
            'Post command is not verified for postprocessing format in SolutionDomain Model'
2225
1755
 
2226
1756
 
2227
 
    def checkGetStatusNodeAndGetFacesSelect(self):
2228
 
        """Check whether status of node and selection pf fzces could be get - only for view"""
2229
 
        mdl = SolutionDomainModel(self.case)
2230
 
        select = {}
2231
 
        select['color'] = '1 2 3'
2232
 
        select['group'] = 'toto'
2233
 
        select['fraction'] = '0.12'
2234
 
        select['plan'] = '0.88'
2235
 
        select['reverse'] = 'off'
2236
 
        select['semiconf'] = 'on'
2237
 
        mdl.setJoinMeshesStatus('on')
2238
 
        mdl.addJoinFaces(select)
2239
 
        node = mdl.node_join.xmlGetChildNode('faces_join')
2240
 
 
2241
 
        assert mdl.getStatusNode(node) == 'on',\
2242
 
            'Could not get status of node in SolutionDomainModel'
2243
 
 
2244
 
        deux = {}
2245
 
        deux['color'] = '4 5 6'
2246
 
        deux['group'] = 'coucou'
2247
 
        deux['fraction'] = '0.1'
2248
 
        deux['plan'] = '0.8'
2249
 
        deux['reverse'] = 'off'
2250
 
        deux['semiconf'] = 'on'
2251
 
        mdl.addJoinFaces(deux)
2252
 
        list = {'group': 'coucou', 'reverse': 'off', 'color': '4 5 6', 'plan': '0.8', 'fraction': '0.1', 'semiconf': 'on'}
2253
 
 
2254
 
        assert mdl.getFacesSelect('faces_join', 1) == list,\
2255
 
            'Could not get faces for view in SolutionDomainModel'
2256
 
 
2257
 
 
2258
 
 
2259
1757
#-------------------------------------------------------------------------------
2260
1758
# SolutionDomain Model test case
2261
1759
#-------------------------------------------------------------------------------
2285
1783
        pass
2286
1784
 
2287
1785
    def checkGetMeshExtension(self):
2288
 
        """Check whether mesh extension could be get"""
 
1786
        """Check whether mesh extension could be got"""
2289
1787
        mdl = MeshModel()
2290
1788
 
2291
1789
        for f in self.files:
2293
1791
          assert ext == f[1], 'could not get the mesh extension'
2294
1792
 
2295
1793
    def checkGetMeshFormat(self):
2296
 
        """Check whether mesh extension could be get"""
 
1794
        """Check whether mesh extension could be got"""
2297
1795
        mdl = MeshModel()
2298
1796
 
2299
1797
        for f in self.files:
2300
 
          fmt = mdl.getMeshFormat(f[0])
2301
 
          if fmt:
2302
 
              assert fmt == mdl.ext[f[1]], 'could not get the mesh format'
 
1798
            m = (f[0], "")
 
1799
            fmt = mdl.getMeshFormat(m)
 
1800
            if fmt:
 
1801
                assert fmt == mdl.ext[f[1]], 'could not get the mesh format'
2303
1802
 
2304
1803
 
2305
1804
def suite1():
2311
1810
    return testSuite
2312
1811
 
2313
1812
def runTest():
2314
 
    print __file__
 
1813
    print(__file__)
2315
1814
    runner = unittest.TextTestRunner()
2316
1815
    runner.run(suite1())
2317
1816
    runner.run(suite2())