1 # Copyright (C) 2012-2014 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 import PARAVIS_Gen_idl
22 import SALOME_ContainerManager_idl
24 from SALOME_NamingServicePy import SALOME_NamingServicePy_i
26 from MEDCouplingCorba import *
28 def createALocalMesh():
29 targetCoords=[ 0., 0., 0., 50., 0., 0. , 200., 0., 0. , 0., 50., 0., 50., 50., 0. , 200., 50., 0., 0., 200., 0., 50., 200., 0. , 200., 200., 0. ,
30 0., 0., 50., 50., 0., 50. , 200., 0., 50. , 0., 50., 50., 50., 50., 50. , 200., 50., 50., 0., 200., 50., 50., 200., 50. , 200., 200., 50. ,
31 0., 0., 200., 50., 0., 200. , 200., 0., 200. , 0., 50., 200., 50., 50., 200. , 200., 50., 200., 0., 200., 200., 50., 200., 200. , 200., 200., 200. ];
32 targetConn=[0,1,4,3,9,10,13,12, 1,2,5,4,10,11,14,13, 3,4,7,6,12,13,16,15, 4,5,8,7,13,14,17,16,
33 9,10,13,12,18,19,22,21, 10,11,14,13,19,20,23,22, 12,13,16,15,21,22,25,24, 13,14,17,16,22,23,26,25];
34 targetMesh=MEDCouplingUMesh.New();
35 targetMesh.setMeshDimension(3);
36 targetMesh.setName("MyMesh3D");
37 targetMesh.setDescription("build3DMesh");
38 targetMesh.allocateCells(12);
40 targetMesh.insertNextCell(NORM_HEXA8,8,targetConn[8*i:8*(i+1)]);
42 targetMesh.finishInsertingCells();
43 myCoords=DataArrayDouble.New();
44 myCoords.setValues(targetCoords,27,3);
45 targetMesh.setCoords(myCoords)
46 myCoords.setName("check in case")
49 def createALocalField1():
51 field=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME)
53 da=DataArrayDouble.New()
54 da.setValues([1.,11.,101.,1001., 2.,12.,102.,1002., 3.,13.,103.,1003., 4.,14.,104.,1004., 5.,15.,105.,1005., 6.,16.,106.,1006., 7.,17.,107.,1007., 8.,18.,108.,1008.,],8,4)
56 field.setName("vitoo")
57 field.setTime(4.5,3,4)
60 def createALocalField2():
62 field=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME)
64 da=DataArrayDouble.New()
65 da.setValues([float(3*i) for i in xrange(27)],27,1)
67 field.setName("vitooNode")
68 field.setTime(4.7,9,14)
71 def createALocalMultiField3():
72 fName="FieldOverTimeCorba"
76 for i in xrange(nbOfFields):
77 fs[i]=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME)
79 da=DataArrayDouble.New()
80 da.setValues([0.,1.,2.+i,3.,4.,5.,7.],8,1)
83 fs[i].setTime(1.2+i,9,14)
85 ret=MEDCouplingFieldOverTime.New(fs);
88 def createALocalCMesh4():
89 mesh=MEDCouplingCMesh.New();
90 coordsX=DataArrayDouble.New();
91 arrX=[ -1., 1., 2., 4. ]
92 coordsX.setValues(arrX,4,1);
93 coordsY=DataArrayDouble.New();
95 coordsY.setValues(arrY,3,1);
96 coordsZ=DataArrayDouble.New();
97 arrZ=[ -3., 3., 6., 12., 17. ]
98 coordsZ.setValues(arrZ,5,1);
99 mesh.setCoords(coordsX,coordsY,coordsZ);
100 mesh.setName("CMeshSample")
103 def createALocalField5():
104 m=createALocalCMesh4()
105 field=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME)
107 da=DataArrayDouble.New()
108 field.setTime(14.5,0,0)
109 da.setValues([float(7*i) for i in xrange(24)],24,1)
110 field.setName("MeshOnCMesh");
117 orb = CORBA.ORB_init([], CORBA.ORB_ID)
118 poa=orb.resolve_initial_references("RootPOA");
119 mgr=poa._get_the_POAManager();
124 naming_service = SALOME_NamingServicePy_i(orb)
125 rp=SALOME_ContainerManager_idl._0_Engines.ResourceParameters("","","",["PARAVIS"],1,10,10,1,1,"first",[])
126 cp=SALOME_ContainerManager_idl._0_Engines.ContainerParameters("","get","",1,False,"",rp)
127 sm=naming_service.Resolve("/ContainerManager")
128 cont=sm.GiveContainer(cp)
129 paraviz=naming_service.Resolve("/Containers/%s/FactoryServer/PARAVIS_inst_1"%(cont.getHostName()))
133 meshCorba=MEDCouplingUMeshServant._this(createALocalMesh())
134 ior=orb.object_to_string(meshCorba)
137 f1=MEDCouplingFieldDoubleServant._this(createALocalField1())
138 ior2=orb.object_to_string(f1)
139 print "Field on cell ",ior2
141 f2=MEDCouplingFieldDoubleServant._this(createALocalField2())
142 ior3=orb.object_to_string(f2)
143 print "Field on node ",ior3
145 fs3=MEDCouplingFieldOverTimeServant._this(createALocalMultiField3())
147 ior4=orb.object_to_string(fs3)
148 print "Fields over time ",ior4
150 m2=MEDCouplingCMeshServant._this(createALocalCMesh4())
151 ior5=orb.object_to_string(m2)
152 print "CMesh 2 : ",ior5
154 f5=MEDCouplingFieldDoubleServant._this(createALocalField5())
155 ior6=orb.object_to_string(f5)
156 print "Field on cell CMesh ",ior6
159 src1 = ParaMEDCorbaPluginSource()
161 asc=GetAnimationScene()
163 dr=Show()\ndr.Visibility = 1
166 content=script%(ior4)
167 paraviz.ExecuteScript(content)