]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM_SWIG/testGaussLocalization.py
Salome HOME
Join modifications from branch CEAFor_V3_2_0
[modules/med.git] / src / MEDMEM_SWIG / testGaussLocalization.py
1 ###################################################################################
2 #
3 # This Python script is to test the API of the C++ GAUSS_LOCALIZATION class
4 # defined in MEDMEM_GaussLocalization.hxx. This test is the Python equivalent
5 # of the test_GaussLocalization.cxx program.
6 #
7 ###################################################################################
8
9 from libMEDMEM_Swig import *
10
11 a = 0.446948490915965
12 b = 0.091576213509771
13 p1 = 0.11169079483905
14 p2 = 0.0549758718227661
15
16 typeGeo = MED_TRIA6
17
18 ngauss = 6
19
20 gaussLocName = "Model n1"
21
22 refCoo = [-1.0,1.0,
23           -1.0,-1.0,
24           1.0,-1.0,
25           -1.0,0.0,
26           0.0,-1.0,
27           0.0,0.0]
28
29 gsCoo = [2*b-1, 1-4*b,
30          2*b-1, 2*b-1,
31          1-4*b, 2*b-1,
32          1-4*a, 2*a-1,
33          2*a-1, 1-4*a,
34          2*a-1, 2*a-1]
35
36 weight = [4*p2, 4*p2, 4*p2, 4*p1, 4*p1, 4*p1]
37
38 interlacingType = MED_FULL_INTERLACE
39
40 gaussLoc = GAUSS_LOCALIZATION_FULL(gaussLocName, typeGeo, ngauss, refCoo,
41                                    gsCoo, weight)
42
43 print "Gauss Localization via the str operator: ", gaussLoc
44
45 print "Gauss Localization via the get methods from the class API"
46
47 typeGeoVerif = gaussLoc.getType()
48
49 ngaussVerif = gaussLoc.getNbGauss()
50
51 gaussLocNameVerif = gaussLoc.getName()
52
53 refCooVerif = gaussLoc.getRefCoo()
54
55 gsCooVerif = gaussLoc.getGsCoo()
56
57 weightVerif = gaussLoc.getWeight()
58
59 interlacingTypeVerif = gaussLoc.getInterlacingType()
60
61 lenrefCoo = len(refCoo)
62 lenrefCooVerif = len(refCooVerif)
63
64 lengsCoo = len(gsCoo)
65 lengsCooVerif = len(gsCooVerif)
66
67 lenweight = len(weight)
68 lenweightVerif = len(weightVerif)
69
70 if (typeGeo != typeGeoVerif):
71     print "the geometric type does not match"
72     print typeGeo, " verif ", typeGeo
73     pass
74
75 if (ngauss != ngaussVerif):
76     print "the number of Gauss points does not match"
77     print ngauss, " verif ", ngaussVerif
78     pass
79
80 if (interlacingType != interlacingTypeVerif):
81     print "the interlacing type does not match"
82     print interlacingType, " verif ", interlacingTypeVerif
83     pass
84
85 if (gaussLocName != gaussLocNameVerif):
86     print "the Gauss Location name does not match"
87     print gaussLocName, " verif ", gaussLocNameVerif
88     pass
89
90 if (lenrefCoo == lenrefCooVerif):
91     print "refCoo verification -- length ",lenrefCoo
92     for i in range(lenrefCoo):
93         if (refCoo[i] != refCooVerif[i]):
94             print " * ",i," ",refCoo[i], " --- ",refCooVerif[i]
95 else:
96     print "the array of referrence element coordinates does not match"
97
98 if (lengsCoo == lengsCooVerif):
99     print "gsCoo verification -- length ",lengsCoo
100     for i in range(lengsCoo):
101         if (gsCoo[i] != gsCooVerif[i]):
102             print " * ",i," ",gsCoo[i], " --- ",gsCooVerif[i]
103 else:
104     print "the array of gauss points coordinates does not match"
105
106 if (lenweight == lenweightVerif):
107     print "weight verification -- length ",lenweight
108     for i in range(lenweight):
109         if (weight[i] != weightVerif[i]):
110             print " * ",i," ",weight[i], " --- ",weightVerif[i]
111 else:
112     print "the array of gauss points weight does not match"
113
114 print "seems to be OK"
115 print ""
116 print "END of the Pyhton script ..... Ctrl D to exit"