Back to index

salome-med  6.5.0
MEDCouplingCorbaSwigTest.py
Go to the documentation of this file.
00001 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 #
00003 # This library is free software; you can redistribute it and/or
00004 # modify it under the terms of the GNU Lesser General Public
00005 # License as published by the Free Software Foundation; either
00006 # version 2.1 of the License.
00007 #
00008 # This library is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 # Lesser General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU Lesser General Public
00014 # License along with this library; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 #
00017 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 #
00019 
00020 from MEDCoupling import *
00021 import math
00022 import os
00023 
00024 class MEDCouplingCorbaServBasicsTest:
00025     def build1DMesh(self):
00026         coords=[ 0.0, 0.3, 0.75, 1.0 ]
00027         conn=[ 0,1, 1,2, 2,3 ]
00028         mesh=MEDCouplingUMesh.New("1DMeshForCorba",1);
00029         mesh.setDescription("build1DMesh");
00030         mesh.allocateCells(3);
00031         mesh.setTime(5.6,7,8);
00032         mesh.setTimeUnit("ms");
00033         mesh.insertNextCell(NORM_SEG2,2,conn[0:2]);
00034         mesh.insertNextCell(NORM_SEG2,2,conn[2:4]);
00035         mesh.insertNextCell(NORM_SEG2,2,conn[4:6]);
00036         mesh.finishInsertingCells();
00037         myCoords=DataArrayDouble.New();
00038         myCoords.setValues(coords,4,1);
00039         mesh.setCoords(myCoords);
00040         mesh.changeSpaceDimension(3);
00041         myCoords=mesh.getCoords();
00042         myCoords.setInfoOnComponent(0,"X1D(m)");
00043         myCoords.setInfoOnComponent(1,"Y1D (dm)");
00044         myCoords.setInfoOnComponent(2,"Z1D (pm)");
00045         center=[0.,0.,0.]
00046         vector=[0.,1.,0.]
00047         mesh.rotate(center,vector,-math.pi/2.);
00048         return mesh
00049         
00050     def build2DMesh(self):
00051         targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ];
00052         targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]
00053         targetMesh=MEDCouplingUMesh.New();
00054         targetMesh.setMeshDimension(2);
00055         targetMesh.setName("MyMesh2D");
00056         targetMesh.setDescription("build2DMesh");
00057         targetMesh.allocateCells(5);
00058         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]);
00059         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7]);
00060         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10]);
00061         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14]);
00062         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18]);
00063         targetMesh.finishInsertingCells();
00064         myCoords=DataArrayDouble.New();
00065         myCoords.setValues(targetCoords,9,2);
00066         targetMesh.setCoords(myCoords);
00067         return targetMesh;
00068     
00069     def build3DMesh(self):
00070         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. ,
00071                        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. ,
00072                        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. ];
00073         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,
00074                     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];
00075         targetMesh=MEDCouplingUMesh.New();
00076         targetMesh.setMeshDimension(3);
00077         targetMesh.setName("MyMesh3D");
00078         targetMesh.setDescription("build3DMesh");
00079         targetMesh.allocateCells(12);
00080         for i in xrange(8):
00081             targetMesh.insertNextCell(NORM_HEXA8,8,targetConn[8*i:8*(i+1)]);
00082             pass
00083         targetMesh.finishInsertingCells();
00084         myCoords=DataArrayDouble.New();
00085         myCoords.setValues(targetCoords,27,3);
00086         targetMesh.setCoords(myCoords)
00087         myCoords.setName("check in case")
00088         return targetMesh;
00089 
00090     def build3DSurfMesh(self):
00091         targetCoords=[-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5];
00092         targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4];
00093         targetMesh=MEDCouplingUMesh.New();
00094         targetMesh.setMeshDimension(2);
00095         targetMesh.setName("MyMesh3DSurf");
00096         targetMesh.setDescription("build3DSurfMesh");
00097         targetMesh.allocateCells(5);
00098         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]);
00099         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7]);
00100         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10]);
00101         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14]);
00102         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18]);
00103         targetMesh.finishInsertingCells();
00104         myCoords=DataArrayDouble.New();
00105         myCoords.setValues(targetCoords,9,3);
00106         targetMesh.setCoords(myCoords);
00107         myCoords.setInfoOnComponent(0,"X (m)");
00108         myCoords.setInfoOnComponent(1,"X (dm)");
00109         myCoords.setInfoOnComponent(2,"X (m)");
00110         return targetMesh;
00111 
00112     def build0DMesh(self):
00113         targetCoords=[-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5];
00114         targetMesh=MEDCouplingUMesh.New();
00115         targetMesh.setMeshDimension(0);
00116         targetMesh.allocateCells(8);
00117         targetMesh.setName("Wonderfull 0D mesh");
00118         targetMesh.setDescription("build0DMesh");
00119         targetConn=[]
00120         targetMesh.insertNextCell(NORM_POINT1,1,[0]);
00121         targetMesh.insertNextCell(NORM_POINT1,1,[1]);
00122         targetMesh.insertNextCell(NORM_POINT1,1,[2]);
00123         targetMesh.insertNextCell(NORM_POINT1,1,[3]);
00124         targetMesh.insertNextCell(NORM_POINT1,1,[4]);
00125         targetMesh.insertNextCell(NORM_POINT1,1,[5]);
00126         targetMesh.insertNextCell(NORM_POINT1,1,[7]);
00127         targetMesh.insertNextCell(NORM_POINT1,1,[6]);
00128         targetMesh.finishInsertingCells();
00129         myCoords=DataArrayDouble.New();
00130         myCoords.setValues(targetCoords,9,3);
00131         targetMesh.setCoords(myCoords);
00132         myCoords.setInfoOnComponent(0,"X (m)");
00133         myCoords.setInfoOnComponent(1,"YY (Pm)");
00134         myCoords.setInfoOnComponent(2,"ZZZ (m)");
00135         targetMesh.checkCoherency();
00136         return targetMesh;
00137 
00138     def buildM1DMesh(self):
00139         meshM1D=MEDCouplingUMesh.New("wonderfull -1 D mesh",-1);
00140         meshM1D.setDescription("buildM1DMesh");
00141         meshM1D.checkCoherency();
00142         return meshM1D;
00143 
00144     def buildExtrudedMesh(self):
00145         m2D=self.build2DMesh();
00146         m2D.changeSpaceDimension(3);
00147         m1D=self.build1DMesh();
00148         retu=m2D.buildExtrudedMesh(m1D,0);
00149         ret=MEDCouplingExtrudedMesh.New(retu,m2D,2);
00150         ret.setName("ExtrudedTestForCorbaTest");
00151         ret.setDescription("buildExtrudedMesh");
00152         return ret;
00153 
00154     def buildCMesh(self):
00155         targetMesh=MEDCouplingCMesh.New();
00156         targetMesh.setTime(2.3,4,5);
00157         targetMesh.setTimeUnit("us");
00158         targetMesh.setName("Example of CMesh");
00159         targetMesh.setDescription("buildCMesh");
00160         a1=DataArrayDouble.New();
00161         a1Data=[3.,4.,5.,6.,7.]
00162         a1.setValues(a1Data,5,1);
00163         a1.setInfoOnComponent(0,"SmthX");
00164         a2=DataArrayDouble.New();
00165         a2Data=[2.78,3.,4.,5.,6.,7.]
00166         a2.setValues(a2Data,6,1);
00167         a2.setInfoOnComponent(0,"SmthZ");
00168         #
00169         targetMesh.setCoordsAt(0,a1);
00170         targetMesh.setCoordsAt(2,a2);
00171         #
00172         #
00173         targetMesh.checkCoherency();
00174         #
00175         return targetMesh;
00176 
00177     def buildFieldScalarOn2DNT(self):
00178         mesh=self.build2DMesh();
00179         fieldOnCells=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
00180         fieldOnCells.setTimeUnit("ms");
00181         fieldOnCells.setName("toto");
00182         fieldOnCells.setMesh(mesh);
00183         array=DataArrayDouble.New();
00184         tmp=mesh.getNumberOfCells()*6*[7.]
00185         array.setValues(tmp,mesh.getNumberOfCells(),6);
00186         fieldOnCells.setArray(array)
00187         fieldOnCells.checkCoherency();
00188         return fieldOnCells;
00189 
00190     def buildFieldNodeScalarOn2DNT(self):
00191         mesh=self.build2DMesh();
00192         fieldOnNodes=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME);
00193         fieldOnNodes.setName("toto2");
00194         fieldOnNodes.setTimeUnit("s");
00195         fieldOnNodes.setDescription("my wonderful field toto2");
00196         fieldOnNodes.setMesh(mesh);
00197         array=DataArrayDouble.New();
00198         tmp=mesh.getNumberOfNodes()*5*[7.1234]
00199         array.setValues(tmp,mesh.getNumberOfNodes(),5);
00200         fieldOnNodes.setArray(array);
00201         fieldOnNodes.checkCoherency();
00202         return fieldOnNodes;
00203 
00204     def buildFieldScalarOn3DNT(self):
00205         mesh=self.build3DMesh();
00206         fieldOnCells=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
00207         fieldOnCells.setNature(ConservativeVolumic);
00208         fieldOnCells.setName("toto");
00209         fieldOnCells.setDescription("my wonderful 3D field toto2");
00210         fieldOnCells.setMesh(mesh);
00211         array=DataArrayDouble.New();
00212         tmp=mesh.getNumberOfCells()*6*[7.]
00213         array.setValues(tmp,mesh.getNumberOfCells(),6);
00214         fieldOnCells.setArray(array);
00215         fieldOnCells.checkCoherency();
00216         return fieldOnCells;
00217 
00218     def buildFieldScalarOn3DSurfWT(self):
00219         mesh=self.build3DSurfMesh();
00220         fieldOnCells=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
00221         fieldOnCells.setName("toto25");
00222         fieldOnCells.setDescription("my wonderful 3D surf field toto25");
00223         fieldOnCells.setTimeUnit("us");
00224         fieldOnCells.setMesh(mesh);
00225         array=DataArrayDouble.New();
00226         tmp=mesh.getNumberOfCells()*3*[7.]
00227         array.setValues(tmp,mesh.getNumberOfCells(),3);
00228         fieldOnCells.setArray(array);
00229         fieldOnCells.setTime(6.7,1,4);
00230         fieldOnCells.checkCoherency();
00231         return fieldOnCells;
00232 
00233     def buildFieldScalarOn3DSurfCOTI(self):
00234         mesh=self.build3DSurfMesh();
00235         fieldOnCells=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL);
00236         fieldOnCells.setName("toto26");
00237         fieldOnCells.setDescription("my wonderful 3D surf field toto26");
00238         fieldOnCells.setTimeUnit("us");
00239         fieldOnCells.setMesh(mesh);
00240         array=DataArrayDouble.New();
00241         tmp=mesh.getNumberOfCells()*3*[7.]
00242         array.setValues(tmp,mesh.getNumberOfCells(),3);
00243         fieldOnCells.setArray(array);
00244         fieldOnCells.setStartTime(6.7,1,4);
00245         fieldOnCells.setEndTime(7.2,2,8);
00246         fieldOnCells.checkCoherency();
00247         return fieldOnCells;
00248 
00249     def buildFieldScalarOn2DLT(self):
00250         mesh=self.build2DMesh()
00251         fieldOnCells=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME)
00252         fieldOnCells.setName("toto27");
00253         fieldOnCells.setDescription("my wonderful 2D field toto27");
00254         fieldOnCells.setTimeUnit("ms");
00255         fieldOnCells.setMesh(mesh);
00256         array=DataArrayDouble.New();
00257         arr1=[1.2,1.02,1.002,1.0002, 3.4,3.04,3.004,3.0004, 5.6,5.06,5.006,5.0006, 7.8,7.08,7.008,7.0008, 9.1,9.01,9.001,9.0001]
00258         array.setValues(arr1,mesh.getNumberOfCells(),4);
00259         fieldOnCells.setArray(array);
00260         array=DataArrayDouble.New();
00261         arr2=[71.2,71.02,71.002,71.0002, 73.4,73.04,73.004,73.0004, 75.6,75.06,75.006,75.0006, 77.8,77.08,77.008,77.0008, 79.1,79.01,79.001,79.0001]
00262         array.setValues(arr2,mesh.getNumberOfCells(),4);
00263         fieldOnCells.setEndArray(array)
00264         fieldOnCells.setStartTime(6.7,25,26);
00265         fieldOnCells.setEndTime(17.2,125,126);
00266         fieldOnCells.checkCoherency();
00267         return fieldOnCells;
00268 
00269     def buildFieldGaussPt2DWT(self):
00270         _a=0.446948490915965;
00271         _b=0.091576213509771;
00272         _p1=0.11169079483905;
00273         _p2=0.0549758718227661;
00274         refCoo1=[ 0.,0., 1.,0., 0.,1. ]
00275         gsCoo1=[ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b,
00276                  2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1]
00277         wg1=[ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 ]
00278         _refCoo1=refCoo1
00279         _gsCoo1=gsCoo1
00280         _wg1=wg1
00281         m=self.build2DMesh();
00282         f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
00283         f.setTime(6.7,1,4);
00284         f.setMesh(m);
00285         f.setGaussLocalizationOnType(NORM_TRI3,_refCoo1,_gsCoo1,_wg1);
00286         refCoo2=[ 0.,0., 1.,0., 1.,1., 0.,1. ]
00287         _refCoo2=refCoo2
00288         _gsCoo1=_gsCoo1[0:4]
00289         _wg1=_wg1[0:2]
00290         f.setGaussLocalizationOnType(NORM_QUAD4,_refCoo2,_gsCoo1,_wg1);
00291         array=DataArrayDouble.New();
00292         ptr=18*2*[None]
00293         for i in xrange(18*2):
00294             ptr[i]=float(i+1);
00295             pass
00296         array.setValues(ptr,18,2);
00297         array.setInfoOnComponent(0,"Power(MW)");
00298         array.setInfoOnComponent(1,"Density (kg/m^3)");
00299         f.setArray(array);
00300         f.setName("MyFirstFieldOnGaussPoint");
00301         f.setTimeUnit("ms");
00302         f.setDescription("mmmmmmmmmmmm");
00303         f.checkCoherency();
00304         return f;
00305 
00306     def buildFieldGaussPtNE2DWT(self):
00307         m=self.build2DMesh();
00308         f=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME);
00309         f.setTime(6.8,11,8);
00310         f.setMesh(m);
00311         f.setTimeUnit("ms");
00312         f.setName("MyFirstFieldOnNE");
00313         f.setDescription("MyDescriptionNE");
00314         array=DataArrayDouble.New();
00315         ptr=18*2*[None]
00316         for i in xrange(18*2):
00317             ptr[i]=float(i+7)
00318         array.setValues(ptr,18,2);
00319         array.setInfoOnComponent(0,"Power(MW)");
00320         array.setInfoOnComponent(1,"Density (kg/m^3)");
00321         f.setArray(array);
00322         #
00323         f.checkCoherency();
00324         return f;
00325 
00326     def buildFieldVectorOnExtrudedWT(self):
00327         ext=self.buildExtrudedMesh();
00328         #
00329         f=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
00330         f.setTime(6.8,11,8);
00331         f.setMesh(ext);
00332         f.setName("MyFieldOnExtruM");
00333         f.setDescription("desc of MyFiOnExtruM");
00334         array=DataArrayDouble.New();
00335         nbOfCells=ext.getNumberOfCells();
00336         ptr=2*nbOfCells*[None]
00337         for i in range(nbOfCells*2):
00338             ptr[i]=float(i/2+7)+float((i%2)*1000);
00339             pass
00340         array.setValues(ptr,nbOfCells,2);
00341         array.setInfoOnComponent(0,"Power(MW)");
00342         array.setInfoOnComponent(1,"Density (kg/m^3)");
00343         f.setArray(array);
00344         #
00345         f.checkCoherency();
00346         return f
00347 
00348     def buildFieldVectorOnCMeshWT(self):
00349         ext=self.buildCMesh();
00350         #
00351         f=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
00352         f.setTime(6.8,11,8);
00353         f.setMesh(ext);
00354         f.setName("MyFieldOnCMesh");
00355         f.setDescription("desc of MyFiOnCMesh");
00356         array=DataArrayDouble.New();
00357         nbOfCells=ext.getNumberOfCells();
00358         ptr=2*nbOfCells*[None]
00359         for i in range(nbOfCells*2):
00360             ptr[i]=float(i/2+7)+float((i%2)*1000);
00361             pass
00362         array.setValues(ptr,nbOfCells,2);
00363         array.setInfoOnComponent(0,"Power(GW)");
00364         array.setInfoOnComponent(1,"Density (kg/m^3)");
00365         f.setArray(array);
00366         #
00367         f.checkCoherency();
00368         return f
00369 
00370     def buildFieldTemplateCellOn2D(self):
00371         f1=self.buildFieldScalarOn2DNT();
00372         f2=MEDCouplingFieldTemplate.New(f1);
00373         f2.setNature(NoNature);
00374         return f2
00375     
00376     def buildFieldTemplateNodeOn2D(self):
00377         f1=self.buildFieldNodeScalarOn2DNT();
00378         f2=MEDCouplingFieldTemplate.New(f1);
00379         f2.setNature(ConservativeVolumic);
00380         return f2
00381             
00382     def buildFieldTemplateGaussPtOn2D(self):
00383         f1=self.buildFieldGaussPt2DWT();
00384         f2=MEDCouplingFieldTemplate.New(f1);
00385         f2.setNature(Integral);
00386         return f2
00387 
00388     def buildFieldTemplateGaussNEOn2D(self):
00389         f1=self.buildFieldGaussPtNE2DWT();
00390         f2=MEDCouplingFieldTemplate.New(f1);
00391         f2.setNature(IntegralGlobConstraint);
00392         return f2
00393 
00394     def buildMultiFields1(self):
00395         m1=self.build2DMesh();
00396         m1.setName("m1");
00397         m2=self.build2DMesh();
00398         m2.setName("m2");
00399         vals0=[-0.7,-1.,-2.,-3.,-4.];
00400         vals1=[0.,1.,2.,3.,4.,0.1,0.2,0.3,0.4];
00401         vals1_1=[170.,171.,172.,173.,174.,170.1,170.2,170.3,170.4];
00402         vals2=[5.,6.,7.,8.,9.];
00403         vals4=[15.,16.,17.,18.,19.];
00404         d0=DataArrayDouble.New();
00405         d0.setValues(vals0,5,1);
00406         d1=DataArrayDouble.New();
00407         d1.setValues(vals1,9,1);
00408         d1_1=DataArrayDouble.New();
00409         d1_1.setValues(vals1_1,9,1);
00410         d2=DataArrayDouble.New();
00411         d2.setValues(vals2,5,1);
00412         d4=DataArrayDouble.New();
00413         d4.setValues(vals4,5,1);
00414         d0.setName("d0"); d1.setName("d1"); d1_1.setName("d1_1"); d2.setName("d2"); d4.setName("d4");
00415         d0.setInfoOnComponent(0,"c1");
00416         d1.setInfoOnComponent(0,"c6");
00417         d1_1.setInfoOnComponent(0,"c9");
00418         d2.setInfoOnComponent(0,"c5");
00419         d4.setInfoOnComponent(0,"c7");
00420         f0=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
00421         f0.setMesh(m1);
00422         f0.setArray(d0);
00423         f0.setTime(0.2,5,6);
00424         f0.setName("f0");
00425         f1=MEDCouplingFieldDouble.New(ON_NODES,LINEAR_TIME);
00426         f1.setMesh(m1);
00427         f1.setArrays([d1,d1_1]);
00428         f1.setStartTime(0.7,7,8);
00429         f1.setEndTime(1.2,9,10);
00430         f1.setName("f1");
00431         f2=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL);
00432         f2.setMesh(m2);
00433         f2.setArray(d2);
00434         f2.setTime(1.2,11,12);
00435         f2.setEndTime(1.5,13,14);
00436         f2.setName("f2");
00437         f3=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
00438         f3.setMesh(m1);
00439         f3.setArray(d2);
00440         f3.setTime(1.7,15,16);
00441         f3.setName("f3");
00442         f4=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
00443         f4.setMesh(m2);
00444         f4.setArray(d4);
00445         f4.setName("f4");
00446         ret=MEDCouplingMultiFields.New([f0,f1,f2,f3,f4]);
00447         return ret;
00448     
00449     def buildArrayDouble1(self):
00450         ret=DataArrayDouble.New();
00451         vals=[2.4,3.2,5.6,9.6,47.6,20.4,24.6,278.1,2.01,3.3,2.4,9.4];
00452         ret.setValues(vals,4,3);
00453         ret.setName("toto");
00454         ret.setInfoOnComponent(0,"sss");
00455         ret.setInfoOnComponent(1,"ppp");
00456         ret.setInfoOnComponent(2,"ttt");
00457         return ret;
00458 
00459     def buildArrayDouble2(self):
00460         ret=DataArrayDouble.New();
00461         ret.setName("titi");
00462         return ret;
00463 
00464     def buildArrayDouble3(self):
00465         ret=DataArrayDouble.New();
00466         ret.setName("titi");
00467         ret.alloc(0,3);
00468         ret.setInfoOnComponent(0,"sss");
00469         ret.setInfoOnComponent(1,"ppp");
00470         ret.setInfoOnComponent(2,"ttt");
00471         return ret;
00472 
00473     def buildArrayInt1(self):
00474         ret=DataArrayInt.New();
00475         vals=[2,3,5,9,47,20,24,278,2,3,2,9];
00476         ret.setValues(vals,4,3);
00477         ret.setName("toto");
00478         ret.setInfoOnComponent(0,"sss");
00479         ret.setInfoOnComponent(1,"ppp");
00480         ret.setInfoOnComponent(2,"ttt");
00481         return ret;
00482 
00483     def buildArrayInt2(self):
00484         ret=DataArrayInt.New();
00485         ret.setName("titi");
00486         return ret;
00487 
00488     def buildArrayInt3(self):
00489         ret=DataArrayInt.New();
00490         ret.setName("titi");
00491         ret.alloc(0,3);
00492         ret.setInfoOnComponent(0,"sss");
00493         ret.setInfoOnComponent(1,"ppp");
00494         ret.setInfoOnComponent(2,"ttt");
00495         return ret;
00496 
00497     def buildMultiFields2(self):
00498         m1=self.build2DMesh();
00499         m1.setName("m1");
00500         m2=self.build2DMesh();
00501         m2.setName("m2");
00502         vals0=[-0.7,-1.,-2.,-3.,-4.];
00503         vals1=[0.,1.,2.,3.,4.,0.1,0.2,0.3,0.4];
00504         vals1_1=[170.,171.,172.,173.,174.];
00505         vals2=[5.,6.,7.,8.,9.];
00506         vals4=[15.,16.,17.,18.,19.];
00507         d0=DataArrayDouble.New();
00508         d0.setValues(vals0,5,1);
00509         d1=DataArrayDouble.New();
00510         d1.setValues(vals1,5,1);
00511         d1_1=DataArrayDouble.New();
00512         d1_1.setValues(vals1_1,5,1);
00513         d2=DataArrayDouble.New();
00514         d2.setValues(vals2,5,1);
00515         d4=DataArrayDouble.New();
00516         d4.setValues(vals4,5,1);
00517         d0.setName("d0"); d1.setName("d1"); d1_1.setName("d1_1"); d2.setName("d2"); d4.setName("d4");
00518         d0.setInfoOnComponent(0,"c1");
00519         d1.setInfoOnComponent(0,"c6");
00520         d1_1.setInfoOnComponent(0,"c9");
00521         d2.setInfoOnComponent(0,"c5");
00522         d4.setInfoOnComponent(0,"c7");
00523         f0=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
00524         f0.setMesh(m1);
00525         f0.setArray(d0);
00526         f0.setTime(0.2,5,6);
00527         f0.setName("f0");
00528         f1=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME);
00529         f1.setMesh(m1);
00530         f1.setArrays([d1,d1_1]);
00531         f1.setStartTime(0.7,7,8);
00532         f1.setEndTime(1.2,9,10);
00533         f1.setName("f1");
00534         f2=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL);
00535         f2.setMesh(m2);
00536         f2.setArray(d2);
00537         f2.setTime(1.2,11,12);
00538         f2.setEndTime(1.5,13,14);
00539         f2.setName("f2");
00540         f3=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
00541         f3.setMesh(m1);
00542         f3.setArray(d2);
00543         f3.setTime(1.7,15,16);
00544         f3.setName("f3");
00545         f4=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
00546         f4.setMesh(m2);
00547         f4.setArray(d4);
00548         f4.setName("f4");
00549         f4.setTime(2.7,25,26);
00550         ret=MEDCouplingFieldOverTime.New([f0,f1,f2,f3,f4]);
00551         ret.checkCoherency();
00552         return ret;
00553 
00554     def buildFileNameForIOR(self):
00555         ret=os.getenv("TMP");
00556         ret+="/entryPointMEDCouplingCorba.ior";
00557         return ret;
00558     pass
00559 
00560 def testMesh():
00561     tab4=[1, 2, 8, 7, 2, 3, 9, 8, 3,
00562           4, 10, 9, 4, 5, 11, 10, 5,
00563           0, 6, 11, 0, 1, 7, 6 ]
00564     nbOfNodes=12
00565     nbOfCells=6
00566     coords=[ 0.024155, 0.04183768725682622, -0.305, 0.04831000000000001, -1.015761910347357e-17,
00567              -0.305, 0.09662000000000001, -1.832979297858306e-18, -0.305, 0.120775, 0.04183768725682623,
00568              -0.305, 0.09662000000000001, 0.08367537451365245, -0.305, 0.04831000000000001, 0.08367537451365246,
00569              -0.305, 0.024155, 0.04183768725682622, -0.2863, 0.04831000000000001, -1.015761910347357e-17, -0.2863, 
00570              0.09662000000000001, -1.832979297858306e-18, -0.2863, 0.120775, 0.04183768725682623, -0.2863, 0.09662000000000001,
00571              0.08367537451365245, -0.2863, 0.04831000000000001, 0.08367537451365246, -0.2863 ]
00572     mesh=MEDCouplingUMesh.New()
00573     mesh.setMeshDimension(2)
00574     mesh.allocateCells(8);
00575     mesh.setName("mesh1")
00576     for i in range(nbOfCells):
00577         mesh.insertNextCell(NORM_QUAD4,4,tab4[4*i:4*(i+1)]);
00578         pass
00579     mesh.finishInsertingCells()
00580     myCoords=DataArrayDouble.New()
00581     myCoords.setValues(coords,nbOfNodes,3);
00582     mesh.setCoords(myCoords);
00583     mesh.checkCoherency();
00584     myFalseConn=DataArrayInt.New()
00585     myFalseConn.setValues(tab4,6,4)
00586     return mesh
00587 
00588 def testField():
00589     #
00590     mesh=testMesh()
00591     nbOfCells=mesh.getNumberOfCells()
00592     field=MEDCouplingFieldDouble.New(ON_CELLS)
00593     field.setMesh(mesh)
00594     field.setNature(Integral)
00595     myCoords=DataArrayDouble.New()
00596     sampleTab=[]
00597     for i in range(nbOfCells*9):
00598         sampleTab.append(float(i))
00599         myCoords.setValues(sampleTab,nbOfCells,9);
00600         pass
00601     field.setArray(myCoords)
00602     return field
00603