Salome HOME
6e9d29cddcbd546d58596ad60e40da94149239e4
[samples/pycalculator.git] / src / PYCALCULATOR / PYCALCULATOR_TEST.py
1 # Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22
23 #============================================================================
24 # File   : PYCALCULATOR_TEST.py
25 # Author : Vadim SANDLER, OPEN CASCADE S.A.S. (vadim.sandler@opencascade.com)
26 #============================================================================
27
28 import os
29
30 import salome
31 salome.salome_init()
32
33 import PYCALCULATOR_ORB
34
35 from medcoupling import *
36 from MEDCouplingCorba import *
37 from MEDLoader import *
38 from MEDCouplingClient import *
39
40 pc = salome.lcc.FindOrLoadComponent('FactoryServer','PYCALCULATOR')
41
42 medFile   = os.path.join(os.getenv("DATA_DIR"), "MedFiles", "pointe.med")
43 meshName  = "maa1"
44 fieldName = "fieldcelldoublevector"
45 print(medFile, meshName, fieldName)
46
47 f = ReadFieldCell(medFile, meshName, 0, fieldName, -1, -1)
48 forig = MEDCouplingFieldDoubleServant._this(f)
49
50 fcopy = pc.Clone(forig)
51 f1    = pc.Add(forig, fcopy)
52 f2    = pc.Mul(forig, fcopy)
53 f3    = pc.AddConstant(forig, 3.5)
54 f4    = pc.MulConstant(forig, 3.5)
55
56 clt_forig = MEDCouplingFieldDoubleClient.New(forig)
57 clt_fcopy = MEDCouplingFieldDoubleClient.New(fcopy)
58 clt_f1 = MEDCouplingFieldDoubleClient.New(f1)
59 clt_f2 = MEDCouplingFieldDoubleClient.New(f2)
60 clt_f3 = MEDCouplingFieldDoubleClient.New(f3)
61 clt_f4 = MEDCouplingFieldDoubleClient.New(f4)
62
63 print("clt_forig:", clt_forig)
64 print("clt_fcopy:", clt_fcopy)
65 print("clt_f1:", clt_f1)
66 print("clt_f2:", clt_f2)
67 print("clt_f3:", clt_f3)
68 print("clt_f4:", clt_f4)