]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM_SWIG/testGaussLocalization.py
Salome HOME
MEDMEM suppression
[modules/med.git] / src / MEDMEM_SWIG / testGaussLocalization.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
11 #
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # Lesser General Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 #
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23
24 ###################################################################################
25 # This Python script is to test the API of the C++ GAUSS_LOCALIZATION class
26 # defined in MEDMEM_GaussLocalization.hxx. This test is the Python equivalent
27 # of the test_GaussLocalization.cxx program.
28 ###################################################################################
29 #
30 from libMEDMEM_Swig import *
31
32 a = 0.446948490915965
33 b = 0.091576213509771
34 p1 = 0.11169079483905
35 p2 = 0.0549758718227661
36
37 typeGeo = MED_TRIA6
38
39 ngauss = 6
40
41 gaussLocName = "Model n1"
42
43 refCoo = [-1.0,1.0,
44           -1.0,-1.0,
45           1.0,-1.0,
46           -1.0,0.0,
47           0.0,-1.0,
48           0.0,0.0]
49
50 gsCoo = [2*b-1, 1-4*b,
51          2*b-1, 2*b-1,
52          1-4*b, 2*b-1,
53          1-4*a, 2*a-1,
54          2*a-1, 1-4*a,
55          2*a-1, 2*a-1]
56
57 weight = [4*p2, 4*p2, 4*p2, 4*p1, 4*p1, 4*p1]
58
59 interlacingType = MED_FULL_INTERLACE
60
61 gaussLoc = GAUSS_LOCALIZATION_FULL(gaussLocName, typeGeo, ngauss, refCoo,
62                                    gsCoo, weight)
63
64 print "Gauss Localization via the str operator: ", gaussLoc
65
66 print "Gauss Localization via the get methods from the class API"
67
68 typeGeoVerif = gaussLoc.getType()
69
70 ngaussVerif = gaussLoc.getNbGauss()
71
72 gaussLocNameVerif = gaussLoc.getName()
73
74 refCooVerif = gaussLoc.getRefCoo()
75
76 gsCooVerif = gaussLoc.getGsCoo()
77
78 weightVerif = gaussLoc.getWeight()
79
80 interlacingTypeVerif = gaussLoc.getInterlacingType()
81
82 lenrefCoo = len(refCoo)
83 lenrefCooVerif = len(refCooVerif)
84
85 lengsCoo = len(gsCoo)
86 lengsCooVerif = len(gsCooVerif)
87
88 lenweight = len(weight)
89 lenweightVerif = len(weightVerif)
90
91 if (typeGeo != typeGeoVerif):
92     print "the geometric type does not match"
93     print typeGeo, " verif ", typeGeo
94     pass
95
96 if (ngauss != ngaussVerif):
97     print "the number of Gauss points does not match"
98     print ngauss, " verif ", ngaussVerif
99     pass
100
101 if (interlacingType != interlacingTypeVerif):
102     print "the interlacing type does not match"
103     print interlacingType, " verif ", interlacingTypeVerif
104     pass
105
106 if (gaussLocName != gaussLocNameVerif):
107     print "the Gauss Location name does not match"
108     print gaussLocName, " verif ", gaussLocNameVerif
109     pass
110
111 if (lenrefCoo == lenrefCooVerif):
112     print "refCoo verification -- length ",lenrefCoo
113     for i in range(lenrefCoo):
114         if (refCoo[i] != refCooVerif[i]):
115             print " * ",i," ",refCoo[i], " --- ",refCooVerif[i]
116 else:
117     print "the array of referrence element coordinates does not match"
118
119 if (lengsCoo == lengsCooVerif):
120     print "gsCoo verification -- length ",lengsCoo
121     for i in range(lengsCoo):
122         if (gsCoo[i] != gsCooVerif[i]):
123             print " * ",i," ",gsCoo[i], " --- ",gsCooVerif[i]
124 else:
125     print "the array of gauss points coordinates does not match"
126
127 if (lenweight == lenweightVerif):
128     print "weight verification -- length ",lenweight
129     for i in range(lenweight):
130         if (weight[i] != weightVerif[i]):
131             print " * ",i," ",weight[i], " --- ",weightVerif[i]
132 else:
133     print "the array of gauss points weight does not match"
134
135 print "seems to be OK"
136 print ""
137 print "END of the Pyhton script ..... Ctrl D to exit"