289
284
node['name'] = str(i)
292
def getJoinSelectionsNumber(self):
296
@return: number of join faces selections
299
return len(self.node_join.xmlGetNodeList('faces_join'))
302
def _addFacesSelect(self, node, select):
287
def _addJoinSelect(self, node, select):
304
289
Private method: Add faces to node (join, periodic) with dictionary select.
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')]:
311
297
node.xmlSetData(txt, sel)
313
299
node.xmlRemoveChild(txt)
315
if select['reverse'] == 'on':
316
node_revers = node.xmlInitNode('faces_reverse', status='on')
318
node.xmlRemoveChild('faces_reverse')
320
if select['semiconf'] == 'on':
321
node_semiconf = node.xmlInitNode('faces_semi_conf', status='on')
323
node.xmlRemoveChild('faces_semi_conf')
326
302
def _getFaces(self, node):
328
Private method: Return values found for color, group .. for node "node"
304
Private method: Return values found for joining for a given node
332
default['group'] = ""
307
default['selector'] =""
333
308
default['fraction'] = ""
335
default['reverse'] = ""
336
default['semiconf'] = ""
309
default['plane'] = ""
310
default['verbosity'] = ""
311
default['visualization'] = ""
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')
344
n_revers = node.xmlGetNode('faces_reverse', 'status')
347
default['reverse'] = n_revers['status']
349
default['reverse'] = "off"
351
n_semi_conf = node.xmlGetNode('faces_semi_conf', 'status')
354
default['semiconf'] = n_semi_conf['status']
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
365
def _removeChildren(self, node):
336
def _removeJoinChildren(self, node):
367
338
Private method: Remove all child nodes of node for one selection
369
for tag in ('faces_color',
340
for tag in ('selector',
375
345
node.xmlRemoveChild(tag)
378
def _getLineCommand(self, node):
380
Private method: Get color group faces and revers satus and fraction
381
and plan datas for ommand line to preprocessor execution
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')
390
line += " --color " + coul
392
line += " --group " + grp
393
if n_revers and n_revers['status'] == "on":
395
if n_semi_conf and n_semi_conf['status'] == "on":
396
line += " --semi-conf"
401
348
#To follow : private methods for periodicity:
402
349
#===========================================
405
def _setPeriodicNewMode(self, perio_name, new_mode):
407
Private method: Set node and mode of periodicity for transformation named 'perio_name'
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
416
def _setTranslationDefault(self, perio_name):
351
def _getPerioNode(self, perio_id):
353
Get node for a given periodicity
356
listNode = self.node_perio.xmlGetNodeList('face_periodicity')
357
if perio_id < len(listNode):
358
node = listNode[perio_id]
362
def _updatePerioSelectionNumbers(self):
364
Update names of periodicity selections
366
listNode = self.node_perio.xmlGetNodeList('face_periodicity')
368
for node in listNode:
370
if int(node['name']) > i:
371
node['name'] = str(i)
374
def _setPeriodicNewMode(self, perio_id, new_mode):
376
Private method: Set node and mode of given periodicity'
378
listNode = self.node_perio.xmlGetNodeList('face_periodicity')
379
if perio_id < len(listNode):
380
node = listNode[perio_id]
381
node['mode'] = new_mode
384
def _setTranslationDefault(self, perio_id):
418
386
Private method: Put default values of translation for periodic translation
420
node = self.node_perio.xmlGetNode('transformation', name=perio_name)
388
node = self._getPerioNode(perio_id)
422
391
nList = node.xmlInitChildNodeList('translation')
426
395
n.xmlSetData('translation_z', self.defaultValues()['transfo_val'])
429
def _setRotation1Default(self, perio_name):
431
Private method: Put default values of translation for periodic translation
433
node = self.node_perio.xmlGetNode('transformation', name=perio_name)
434
nList = node.xmlInitChildNodeList('rotation1')
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'])
445
def _setRotation2Default(self, perio_name):
447
Private method: Put default values of translation for periodic translation
449
node = self.node_perio.xmlGetNode('transformation', name=perio_name)
450
nList = node.xmlInitChildNodeList('rotation2')
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):
400
Private method: Put default values of translation for periodic translation
402
node = self._getPerioNode(perio_id)
405
nList = node.xmlInitChildNodeList('rotation')
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'])
416
def _setMixedDefault(self, perio_id):
418
Private method: Put default values of translation for periodic translation
420
node = self._getPerioNode(perio_id)
423
nList = node.xmlInitChildNodeList('mixed')
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)
459
433
#************************* Methods callable by users*****************************
435
# Methods to manage the mesh_input path
436
#======================================
438
def getMeshInput(self):
440
Public method. Return the mesh_input file or directory path.
442
mesh_input = self.node_ecs.xmlGetNode('mesh_input', 'path')
444
return mesh_input['path']
449
def setMeshInput(self, mesh_input):
451
Public method. Add mesh_input path name in xml file.
457
node = self.node_ecs.xmlInitNode('mesh_input', 'path')
459
node['path'] = mesh_input
461
464
# Methods to manage meshes :
462
465
#=========================
464
def addMesh(self, mesh, format=None):
467
def addMesh(self, mesh):
466
469
Public method. Add mesh name in xml file.
468
471
self.isNotInList(mesh, self.getMeshList())
470
format = MeshModel().getMeshFormat(mesh)
474
self.node_meshes.xmlInitNode('mesh', name=mesh[0], path=mesh[1])
472
self.isInList(format, MeshModel().ext.values())
474
self.node_meshes.xmlInitNode('mesh', name=mesh, format=format)
475
self._updateBatchScriptFile('MESH')
476
self.node_meshes.xmlInitNode('mesh', name=mesh[0])
478
479
def delMesh(self, mesh):
480
481
Public method. Delete node for mesh named "mesh" in xml file
482
self.isInList(mesh, self.getMeshList())
483
nodeList = self.node_meshes.xmlGetNodeList('mesh', 'name')
484
for node in nodeList:
485
if node['name'] == mesh:
487
self._updateBatchScriptFile('MESH')
483
node = self._getMeshNode(mesh)
490
487
def getMeshList(self):
753
784
# Methods to manage periodicity :
754
785
#==============================
756
def getPeriodicityListName(self):
760
@return: list of name of defined periodic transformation
764
for node in self.node_perio.xmlGetNodeList('transformation'):
765
l.append(node['name'])
769
def getPeriodicityNumber(self):
773
@return: number of "periodic_boundary" markup in xml file
787
def getPeriodicSelectionsCount(self):
791
@return: number of periodic faces selections
776
return len(self.node_perio.xmlGetNodeList('transformation'))
779
def getPeriodicityMode(self, perio_name):
794
return len(self.node_perio.xmlGetNodeList('face_periodicity'))
797
def getPeriodicityMode(self, perio_id):
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}
788
self.isInList(perio_name, self.getPeriodicityListName())
806
node = self._getPerioNode(perio_id)
790
node = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
791
808
mode = node['mode']
793
810
mode = self.defaultValues()['perio_mode']
794
self.addPeriodicity(perio_name)
798
def addPeriodicity(self, perio_name):
802
Add a new transformation in periodic boundary.
804
@type perio_name: C{str}
805
@param perio_name: name of the periodic boundary
807
self.isNotInList(perio_name, self.getPeriodicityListName())
809
m = self.defaultValues()['perio_mode']
810
self.node_perio.xmlInitNode('transformation', mode="", name=perio_name)
811
self.updatePeriodicityMode(perio_name, m)
814
def updatePeriodicityMode(self, perio_name, mode):
815
def updatePeriodicityMode(self, perio_id, mode):
818
819
Update transformation mode from a periodic boundary
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')
825
self.isInList(perio_name, self.getPeriodicityListName())
826
self.isInList(mode, ('translation', 'rotation1', 'rotation2', 'tr+rota1', 'tr+rota2'))
828
node = self.node_perio.xmlGetNode('transformation', name=perio_name)
826
node = self._getPerioNode(perio_id)
828
self.isInList(mode, ('translation', 'rotation', 'mixed'))
829
830
if node['mode'] != mode:
830
831
node['mode'] = mode
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)
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)
852
self._updateBatchScriptFile('COMMAND_PERIO')
855
def deletePeriodicity(self, perio_name):
836
self._setTranslationDefault(perio_id)
837
elif mode =="rotation":
838
self._setRotationDefault(perio_id)
840
self._setMixedDefault(perio_id)
843
def deletePeriodicity(self, perio_id):
859
847
Delete a transformation in periodic boundary.
861
@type perio_name: C{str}
862
@param perio_name: name of the periodic boundary
864
self.isInList(perio_name, self.getPeriodicityListName())
865
self.node_perio.xmlGetNode('transformation', name=perio_name).xmlRemoveNode()
867
if len(self.node_perio.xmlGetNodeList('transformation')) == 0:
868
self._updateBatchScriptFile('PERIO_OFF')
870
self._updateBatchScriptFile('COMMAND_PERIO')
873
def changePeriodicityName(self, perio_name, new_name):
877
Change the label name of a periodic boundary
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
884
self.isInList(perio_name, self.getPeriodicityListName())
885
node = self.node_perio.xmlGetNode('transformation', name=perio_name)
886
node['name'] = new_name
889
def getTranslationDirection(self, perio_name):
849
@type perio_id: C{str}
850
@param perio_id: name of the periodic boundary
852
node = self._getPerioNode(perio_id)
854
if perio_id < self.getPeriodicSelectionsCount():
855
self._updatePerioSelectionNumbers()
858
def getTranslationDirection(self, perio_id):
893
862
Get values of translation for periodic translation
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}
900
self.isInList(perio_name, self.getPeriodicityListName())
869
node = self._getPerioNode(perio_id)
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
911
def setTranslationDirection(self, perio_name, dir, valcoor):
879
def setTranslationDirection(self, perio_id, dir, valcoor):
913
881
Put values of translation for periodic translation
915
883
self.isFloat(valcoor)
916
self.isInList(perio_name, self.getPeriodicityListName())
917
self.isInList(dir, ("translation_x", "translation_y", "translation_z"))
919
node = self.node_perio.xmlGetNode('transformation', name=perio_name)
884
self.isInList(dir, ('translation_x', 'translation_y', 'translation_z'))
886
node = self._getPerioNode(perio_id)
920
888
for n in node.xmlGetChildNodeList('translation'):
921
889
n.xmlSetData(dir, valcoor)
922
self._updateBatchScriptFile('COMMAND_PERIO')
925
def getRotationDirection(self, perio_name):
892
def getRotationDirection(self, perio_id):
927
894
Get values for director vector rotation for periodic translation
929
self.isInList(perio_name, self.getPeriodicityListName())
896
node = self._getPerioNode(perio_id)
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')
937
903
return rx, ry, rz
940
def setRotationVector(self, perio_name, dir, valcoor):
906
def setRotationVector(self, perio_id, dir, valcoor):
942
908
Put values for director vector rotation for periodic translation
944
910
self.isFloat(valcoor)
945
self.isInList(perio_name, self.getPeriodicityListName())
946
self.isInList(dir, ("rotation_x", "rotation_y", "rotation_z"))
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"))
913
node = self._getPerioNode(perio_id)
915
n = node.xmlGetChildNode('rotation')
950
916
n.xmlSetData(dir,valcoor)
951
self._updateBatchScriptFile('COMMAND_PERIO')
954
def getRotationAngle(self, perio_name):
919
def getRotationAngle(self, perio_id):
956
921
Get angle for rotation for periodic rotation
958
self.isInList(perio_name, self.getPeriodicityListName())
923
node = self._getPerioNode(perio_id)
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')
967
def setRotationAngle(self, perio_name, angle):
931
def setRotationAngle(self, perio_id, angle):
969
933
Put angle for rotation for periodic rotation
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')
979
def getRotationCenter(self, perio_name):
937
node = self._getPerioNode(perio_id)
939
n = node.xmlGetChildNode('rotation')
940
n.xmlSetData('angle', angle)
943
def getRotationCenter(self, perio_id):
981
945
Get coordinates of center of rotation for periodic transformation
983
self.isInList(perio_name, self.getPeriodicityListName())
984
mode = self.getPeriodicityMode(perio_name)
985
self.isInList(mode, ('rotation1', 'rotation2', 'tr+rota1', 'tr+rota2'))
987
node = self.node_perio.xmlGetNode('transformation', name=perio_name)
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'))
950
node = self._getPerioNode(perio_id)
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')
997
958
return px, py, pz
1000
def setRotationCenter(self, perio_name, pos, val):
961
def setRotationCenter(self, perio_id, pos, val):
1002
963
Put coordinates of center of rotation for periodic transformation
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'))
1010
node = self.node_perio.xmlGetNode('transformation', name=perio_name)
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'))
970
node = self._getPerioNode(perio_id)
972
if mode == 'rotation':
973
n = node.xmlGetChildNode('rotation')
1016
974
n.xmlSetData(pos, val)
1017
self._updateBatchScriptFile('COMMAND_PERIO')
1020
def getRotationMatrix(self, perio_name):
977
def getTransformationMatrix(self, perio_id):
1022
979
Get values of matrix of rotation for periodic transformation
1024
self.isInList(perio_name, self.getPeriodicityListName())
1025
mode = self.getPeriodicityMode(perio_name)
1026
self.isInList(mode, ('rotation2', 'tr+rota2'))
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')
1040
return m11, m12, m13, m21, m22, m23, m31, m32, m33
1043
def setRotationMatrix(self, perio_name, pos, val):
981
mode = self.getPeriodicityMode(perio_id)
982
self.isInList(mode, ('mixed'))
984
node = self._getPerioNode(perio_id)
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')
1000
return m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34
1003
def setTransformationMatrix(self, perio_id, pos, val):
1045
1005
Put values of matrix of rotation for periodic transformation
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'))
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'))
1014
node = self._getPerioNode(perio_id)
1016
n = node.xmlGetChildNode('mixed')
1057
1017
n.xmlSetData(pos, val)
1058
self._updateBatchScriptFile('COMMAND_PERIO')
1020
def addPeriodicFaces(self, select):
1022
Add faces selection for periodic transformation.
1023
Select is a dictionary with 'selector', 'fraction', 'plane', 'verbosity', 'visualization'
1025
nb = self.getPeriodicSelectionsCount()
1027
node = self.node_perio.xmlAddChild('face_periodicity', mode="", name=name)
1028
self._addJoinSelect(node, select)
1029
self.updatePeriodicityMode(nb, 'translation')
1032
def getPeriodicFaces(self, perio_id):
1036
@return: faces selection for given periodic transformation
1037
@rtype: C{dictionary}
1041
node = self._getPerioNode(perio_id)
1043
result = self._getFaces(node)
1048
def replacePeriodicFaces(self, perio_id, select):
1050
Replace values of faces selection for periodic transformation, by select
1053
node = self._getPerioNode(perio_id)
1056
self._removeJoinChildren(node)
1057
self._addJoinSelect(node, select)
1061
1060
# Methods to manage faces :
1062
1061
#========================
1063
def getJoinSelectionsCount(self):
1067
@return: number of join faces selections
1070
return len(self.node_join.xmlGetNodeList('face_joining'))
1064
1073
def addJoinFaces(self, select):
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'
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')
1076
def getJoinFaces(self, number):
1078
Return faces selection named 'number' for join meshes .
1080
self.isLowerOrEqual(int(number), int(self.getJoinSelectionsNumber()))
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)
1084
def getJoinFaces(self, join_id):
1086
Return faces selection named 'number' for face joining .
1088
node = self._getJoinNode(join_id)
1083
1089
return self._getFaces(node)
1086
def replaceJoinFaces(self, number, select):
1088
Replace values of faces selection named 'number' for join meshes, by select
1090
self.isLowerOrEqual(int(number), int(self.getJoinSelectionsNumber()))
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')
1098
def deleteJoinFaces(self, number):
1100
Delete faces selection named 'number' for join meshes
1102
self.isLowerOrEqual(int(number), int(self.getJoinSelectionsNumber()))
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')
1111
def setJoinStatus(self, number, status):
1113
Set status of faces selection named 'number' for join meshes
1115
self.isOnOff(status)
1116
self.isLowerOrEqual(int(number), int(self.getJoinSelectionsNumber()))
1118
node = self.node_join.xmlGetNode('faces_join', 'status', name=number)
1119
node['status'] = status
1122
def getJoinStatus(self, number):
1124
Get status of faces selection named 'number' for join meshes
1126
self.isLowerOrEqual(int(number), int(self.getJoinSelectionsNumber()))
1128
return self.node_join.xmlGetNode('faces_join', 'status', name=number)['status']
1131
def addPeriodicFaces(self, perio_name, select):
1133
Add faces selection for periodic transformation.
1134
Select is a dictionary with 'color', 'group', 'fraction', 'plan' ...
1136
self.isInList(perio_name, self.getPeriodicityListName())
1137
node_tr = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
1139
node = node_tr.xmlAddChild('faces_periodic', status="on")
1140
self._addFacesSelect(node, select)
1141
self._updateBatchScriptFile('COMMAND_PERIO')
1144
def getPeriodicFaces(self, perio_name):
1148
@return: faces selection for periodic transformation named perio_name
1149
@rtype: C{dictionary}
1151
self.isInList(perio_name, self.getPeriodicityListName())
1153
node_tr = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
1155
node = node_tr.xmlGetChildNode('faces_periodic', 'status')
1156
if node and node['status'] == 'on':
1157
result = self._getFaces(node)
1162
def replacePeriodicFaces(self, perio_name, select):
1164
Replace values of faces selection for periodic transformation, by select
1166
self.isInList(perio_name, self.getPeriodicityListName())
1167
node_tr = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
1169
node = node_tr.xmlGetChildNode('faces_periodic', status="on")
1170
self._removeChildren(node)
1171
self._addFacesSelect(node, select)
1172
self._updateBatchScriptFile('COMMAND_PERIO')
1175
def deletePeriodicFaces(self, perio_name):
1177
Delete faces selection for periodic transformation named 'perio_name'
1179
self.isInList(perio_name, self.getPeriodicityListName())
1180
node_tr = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
1182
node = node_tr.xmlGetChildNode('faces_periodic', status="on")
1183
node.xmlRemoveNode()
1184
self._updateBatchScriptFile('COMMAND_PERIO')
1187
def setPeriodicStatus(self, perio_name, status):
1189
Set status of faces for periodic transformation named 'perio_name'
1191
self.isOnOff(status)
1192
node_tr = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
1194
node = node_tr.xmlGetChildNode('faces_periodic', 'status')
1196
node['status'] = status
1198
self._updateBatchScriptFile('COMMAND_PERIO')
1201
def getPeriodicStatus(self, perio_name):
1203
Get status of faces for periodic transformation named 'perio_name'
1205
node_tr = self.node_perio.xmlGetNode('transformation', 'mode', name=perio_name)
1207
node = node_tr.xmlGetChildNode('faces_periodic', 'status')
1209
status = node['status']
1212
raise ValueError, "wrong periodicity"
1215
def addSelectFaces(self, select):
1217
Add faces selection for standalone selection.
1218
Select is a dictionary with 'color', 'group', 'fraction', 'plan' ...
1220
node = self.node_standalone.xmlGetChildNode('faces_select', 'status')
1222
node['status'] = "on"
1224
node = self.node_standalone.xmlAddChild('faces_select', status="on")
1225
select['fraction'] =""
1227
select['semiconf'] = ""
1228
self._addFacesSelect(node, select)
1231
def getSelectFaces(self):
1233
Return faces selection for standalone selection (only one authorized selection)
1236
node = self.node_standalone.xmlGetChildNode('faces_select', status="on")
1238
result = self._getFaces(node)
1243
def replaceSelectFaces(self, select):
1245
Replace values of faces selection for standalone selection (only one authorized selection)
1248
node = self.node_standalone.xmlGetChildNode('faces_select', status="on")
1249
self._removeChildren(node)
1250
select['fraction'] =""
1252
select['semiconf'] = ""
1253
self._addFacesSelect(node, select)
1256
def deleteSelectFaces(self):
1258
Delete faces selection for standalone selection (only one authorized selection)
1260
node = self.node_standalone.xmlGetChildNode('faces_select', 'status')
1261
node.xmlRemoveNode()
1264
def setSelectStatus(self, status):
1266
Set status of faces selection for standalone selection (only one authorized selection)
1268
self.isOnOff(status)
1269
node = self.node_standalone.xmlInitNode('faces_select', 'status')
1271
self.deleteSelectFaces()
1273
node['status'] = status
1276
def getSelectStatus(self):
1278
Get status of faces selection for standalone selection (only one authorized selection)
1280
node = self.node_standalone.xmlInitChildNode('faces_select', 'status')
1281
status = node['status']
1283
status = self.defaultValues()['select_status']
1284
self.deleteSelectFaces()
1289
# In following methods we build command for "lance" file
1290
#=======================================================
1092
def replaceJoinFaces(self, join_id, select):
1094
Replace values of faces selection named 'number' for face joining, by select
1096
node = self._getJoinNode(join_id)
1097
self._removeJoinChildren(node)
1098
self._addJoinSelect(node, select)
1101
def deleteJoinFaces(self, join_id):
1103
Delete faces selection named 'number' for face joining
1105
node = self._getJoinNode(join_id)
1106
node.xmlRemoveNode()
1107
if join_id < self.getJoinSelectionsCount():
1108
self._updateJoinSelectionNumbers()
1111
# In following methods we build the command to run the Preprocessor
1112
#==================================================================
1292
1114
def getMeshCommand(self):
1563
1233
assert mdl.getSimCommStatus() == 'on', \
1564
1234
'Could not get status of node simulation_communication'
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"""
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">
1574
<translation_x>0</translation_x>
1575
<translation_y>0</translation_y>
1576
<translation_z>0</translation_z>
1579
<transformation mode="translation" name="2">
1581
<translation_x>0</translation_x>
1582
<translation_y>0</translation_y>
1583
<translation_z>0</translation_z>
1586
</periodic_boundary>'''
1245
mdl.addPeriodicFaces(select)
1246
mdl.addPeriodicFaces(select)
1247
doc ='''<face_periodicity mode="translation" name="1">
1249
<translation_x>0</translation_x>
1250
<translation_y>0</translation_y>
1251
<translation_z>0</translation_z>
1254
<face_periodicity mode="translation" name="2">
1256
<translation_x>0</translation_x>
1257
<translation_y>0</translation_y>
1258
<translation_z>0</translation_z>
1260
</face_periodicity>'''
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'
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 """
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">
1602
<translation_x>0</translation_x>
1603
<translation_y>0</translation_y>
1604
<translation_z>0</translation_z>
1607
<transformation mode="tr+rota1" name="2">
1609
<translation_x>0</translation_x>
1610
<translation_y>0</translation_y>
1611
<translation_z>0</translation_z>
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>
1623
</periodic_boundary>'''
1276
mdl.addPeriodicFaces(select)
1277
mdl.addPeriodicFaces(select)
1278
mdl.updatePeriodicityMode('2', "rotation")
1279
doc ='''<face_periodicity mode="translation" name="1">
1281
<translation_x>0</translation_x>
1282
<translation_y>0</translation_y>
1283
<translation_z>0</translation_z>
1285
</face_periodicity mode="rotation" name="2">
1287
<translation_x>0</translation_x>
1288
<translation_y>0</translation_y>
1289
<translation_z>0</translation_z>
1296
<invariant_x>0</invariant_x>
1297
<invariant_y>0</invariant_y>
1298
<invariant_z>0</invariant_z>
1300
</face_periodicity>'''
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'
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"""
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">
1639
<translation_x>0</translation_x>
1640
<translation_y>3</translation_y>
1641
<translation_z>0</translation_z>
1644
</periodic_boundary>'''
1319
doc ='''<face_periodicity mode="translation" name="1">
1321
<translation_x>0</translation_x>
1322
<translation_y>3</translation_y>
1323
<translation_z>0</translation_z>
1325
</face_periodicity>'''
1646
1327
assert mdl.node_perio == self.xmlNodeFromString(doc),\
1647
1328
'Could not set one direction values for translation'
1694
1379
assert mdl.getRotationCenter('2') == ('0', '9.8', '0'),\
1695
1380
'Could not get value of center of rotation for rotation transformation mode'
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 """
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">
1706
<translation_x>0.0</translation_x>
1707
<translation_y>0.0</translation_y>
1708
<translation_z>0.0</translation_z>
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>
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">
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>
1409
</face_periodicity>'''
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',
1415
'31.31','0', '0', '0'),\
1416
'Could not get values for matrix of rotation for mixed transformation mode'
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 """
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"/>
1428
doc = '''<face_joining name="1">
1429
<selector>1 or 2 or 3 or toto</selector>
1430
<fraction>0.1</fraction>
1432
<verbosity>1</verbosity>
1433
<visualization>1</visualization>
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'
1760
def checkReplaceandDeleteandSetandGetStatusForJoinFaces(self):
1443
def checkReplaceandDeleteandSetandGetForJoinFaces(self):
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
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'
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"/>
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>
1464
<face_joining name="1">
1465
<selector>1 or 2 or 3 or toto</selector>
1466
<fraction>0.1</fraction>
1468
<verbosity>1</verbosity>
1469
<visualization>1</visualization>
1471
<face_joining name="2">
1472
<selector>9 or 8 or 7 or coucou</selector>
1473
<fraction>0.2</fraction>
1475
<verbosity>2</verbosity>
1476
<visualization>2</visualization>
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',
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'
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"/>
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>
1490
<face_joining name="1">
1491
<selector>1 or 2 or 3 or toto</selector>
1492
<fraction>0.1</fraction>
1494
<verbosity>1</verbosity>
1495
<visualization>1</visualization>
1497
<face_joining name="2">
1498
<selector>9 or 8 or 7 or coucou</selector>
1499
<fraction>0.2</fraction>
1501
<verbosity>2</verbosity>
1502
<visualization>2</visualization>
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'
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>
1511
<face_joining name="1">
1512
<selector>9 or 8 or 7 or coucou</selector>
1513
<fraction>0.2</fraction>
1515
<verbosity>2</verbosity>
1516
<visualization>2</visualization>
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'
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>
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"/>
1525
<face_joining name="1">
1526
<selector>9 or 8 or 7 or coucou</selector>
1527
<fraction>0.2</fraction>
1529
<verbosity>2</verbosity>
1530
<visualization>2</visualization>
1532
<face_joining name="2">
1533
<selector>1 or 2 or 3 or toto</selector>
1534
<fraction>0.1</fraction>
1536
<verbosity>1</verbosity>
1537
<visualization>1</visualization>
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'
1863
1544
def checkAddandGetPeriodicFaces(self):
1864
1545
""" Check whether faces of periodicity could be added and get """
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">
1881
<translation_x>0</translation_x>
1882
<translation_y>0</translation_y>
1883
<translation_z>0</translation_z>
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>
1892
<transformation mode="rotation1" name="2">
1894
<translation_x>0</translation_x>
1895
<translation_y>0</translation_y>
1896
<translation_z>0</translation_z>
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>
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>
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>
1562
<translation_x>0</translation_x>
1563
<translation_y>0</translation_y>
1564
<translation_z>0</translation_z>
1567
<face_periodicity mode="rotation" name="2">
1569
<translation_x>0</translation_x>
1570
<translation_y>0</translation_y>
1571
<translation_z>0</translation_z>
1578
<invariant_x>0</invariant_x>
1579
<invariant_y>0</invariant_y>
1580
<invariant_z>0</invariant_z>
1582
<face_periodicity status="on">
1583
<selector>5 or 6 or toto</selector>
1584
<fraction>0.1</fraction>
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'
1921
1595
def checkReplaceandDeleteandSetandGetStatusForPeriodicFaces(self):
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
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">
1943
<translation_x>0.0</translation_x>
1944
<translation_y>0.0</translation_y>
1945
<translation_z>0.0</translation_z>
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>
1954
<transformation mode="rotation1" name="2">
1956
<translation_x>0.0</translation_x>
1957
<translation_y>0.0</translation_y>
1958
<translation_z>0.0</translation_z>
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>
1970
</periodic_boundary>'''
1607
mdl.addPeriodicFaces(select)
1608
mdl.addPeriodicFaces(select)
1609
mdl.updatePeriodicityMode('2', 'rotation')
1610
doc = '''<face_periodicity mode="translation" name="1">
1612
<translation_x>0.0</translation_x>
1613
<translation_y>0.0</translation_y>
1614
<translation_z>0.0</translation_z>
1616
<selector>5 or 6 or toto</selector>
1617
<fraction>0.1</fraction>
1619
<verbosity>1</verbosity>
1620
<visualization>1</visualization>
1622
<face_periodic mode="rotation" name="2">
1624
<translation_x>0.0</translation_x>
1625
<translation_y>0.0</translation_y>
1626
<translation_z>0.0</translation_z>
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>
1637
</face_periodicity>'''
1972
1639
assert mdl.node_perio == self.xmlNodeFromString(doc),\
1973
1640
'Could not delete one selection of faces for periodicities'
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">
1985
<translation_x>0.0</translation_x>
1986
<translation_y>0.0</translation_y>
1987
<translation_z>0.0</translation_z>
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>
1996
<transformation mode="rotation1" name="2">
1998
<translation_x>0.0</translation_x>
1999
<translation_y>0.0</translation_y>
2000
<translation_z>0.0</translation_z>
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>
2012
</periodic_boundary>'''
1648
doc = '''<face_periodicity mode="translation" name="1">
1650
<translation_x>0.0</translation_x>
1651
<translation_y>0.0</translation_y>
1652
<translation_z>0.0</translation_z>
1654
<selector>147 or 963 or PERIODIC</selector>
1655
<fraction>0.1</fraction>
1657
<verbosity>1</verbosity>
1658
<visualization>1</visualization>
1660
</face_periodicity mode="rotation" name="2">
1662
<translation_x>0.0</translation_x>
1663
<translation_y>0.0</translation_y>
1664
<translation_z>0.0</translation_z>
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>
1675
</face_periodicity>'''
2013
1676
assert mdl.node_perio == self.xmlNodeFromString(doc),\
2014
1677
'Could not replace values of faces for periodicities'
2016
mdl.setPeriodicStatus('1', 'off')
2017
doc = '''<periodic_boundary>
2018
<transformation mode="translation" name="1">
2020
<translation_x>0.0</translation_x>
2021
<translation_y>0.0</translation_y>
2022
<translation_z>0.0</translation_z>
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>
2031
<transformation mode="rotation1" name="2">
2033
<translation_x>0.0</translation_x>
2034
<translation_y>0.0</translation_y>
2035
<translation_z>0.0</translation_z>
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>
2047
</periodic_boundary>'''
1679
doc = '''<face_periodicity mode="translation" name="1">
1680
<selector>147 or 963 or PERIODIC</selector>
1681
<fraction>0.1</fraction>
1683
<verbosity>1</verbosity>
1684
<visualization>1</visualization>
1686
<translation_x>0.0</translation_x>
1687
<translation_y>0.0</translation_y>
1688
<translation_z>0.0</translation_z>
1691
<face_periodicity mode="rotation" name="2">
1693
<translation_x>0.0</translation_x>
1694
<translation_y>0.0</translation_y>
1695
<translation_z>0.0</translation_z>
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>
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'
2053
def checkAddandGetSelectFaces(self):
2054
""" Check whether faces of standalone could be added and get """
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>
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'
2075
def checkReplaceandDeleteandSetandGetStatusForSelectFaces(self):
2077
Check whether faces of standalone could be replaced and deleted
2078
and status could be set and get
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)
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>
2100
assert mdl.node_standalone == self.xmlNodeFromString(doc),\
2101
'Could not replace values of faces for standalone selection'
2103
mdl.deleteSelectFaces()
2104
doc = '''<standalone/>'''
2106
assert mdl.node_standalone == self.xmlNodeFromString(doc),\
2107
'Could not delete values of faces for standalone selection'
2109
select['group'] = 'NOUVEAU'
2110
mdl.addSelectFaces(select)
2111
mdl.setSelectStatus('off')
2112
doc = '''<standalone/>'''
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'
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 '''
2128
1718
assert mdl.getMeshCommand() == line,\
2129
1719
'Mesh command is not verified in SolutionDomain Model'
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"/>'''