Back to index

salome-med  6.5.0
testGaussLocalization.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00006 #
00007 # This library is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU Lesser General Public
00009 # License as published by the Free Software Foundation; either
00010 # version 2.1 of the License.
00011 #
00012 # This library is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 # Lesser General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU Lesser General Public
00018 # License along with this library; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020 #
00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00022 #
00023 
00024 ###################################################################################
00025 # This Python script is to test the API of the C++ GAUSS_LOCALIZATION class
00026 # defined in MEDMEM_GaussLocalization.hxx. This test is the Python equivalent
00027 # of the test_GaussLocalization.cxx program.
00028 ###################################################################################
00029 #
00030 from libMEDMEM_Swig import *
00031 
00032 a = 0.446948490915965
00033 b = 0.091576213509771
00034 p1 = 0.11169079483905
00035 p2 = 0.0549758718227661
00036 
00037 typeGeo = MED_TRIA6
00038 
00039 ngauss = 6
00040 
00041 gaussLocName = "Model n1"
00042 
00043 refCoo = [-1.0,1.0,
00044           -1.0,-1.0,
00045           1.0,-1.0,
00046           -1.0,0.0,
00047           0.0,-1.0,
00048           0.0,0.0]
00049 
00050 gsCoo = [2*b-1, 1-4*b,
00051          2*b-1, 2*b-1,
00052          1-4*b, 2*b-1,
00053          1-4*a, 2*a-1,
00054          2*a-1, 1-4*a,
00055          2*a-1, 2*a-1]
00056 
00057 weight = [4*p2, 4*p2, 4*p2, 4*p1, 4*p1, 4*p1]
00058 
00059 interlacingType = MED_FULL_INTERLACE
00060 
00061 gaussLoc = GAUSS_LOCALIZATION_FULL(gaussLocName, typeGeo, ngauss, refCoo,
00062                                    gsCoo, weight)
00063 
00064 print "Gauss Localization via the str operator: ", gaussLoc
00065 
00066 print "Gauss Localization via the get methods from the class API"
00067 
00068 typeGeoVerif = gaussLoc.getType()
00069 
00070 ngaussVerif = gaussLoc.getNbGauss()
00071 
00072 gaussLocNameVerif = gaussLoc.getName()
00073 
00074 refCooVerif = gaussLoc.getRefCoo()
00075 
00076 gsCooVerif = gaussLoc.getGsCoo()
00077 
00078 weightVerif = gaussLoc.getWeight()
00079 
00080 interlacingTypeVerif = gaussLoc.getInterlacingType()
00081 
00082 lenrefCoo = len(refCoo)
00083 lenrefCooVerif = len(refCooVerif)
00084 
00085 lengsCoo = len(gsCoo)
00086 lengsCooVerif = len(gsCooVerif)
00087 
00088 lenweight = len(weight)
00089 lenweightVerif = len(weightVerif)
00090 
00091 if (typeGeo != typeGeoVerif):
00092     print "the geometric type does not match"
00093     print typeGeo, " verif ", typeGeo
00094     pass
00095 
00096 if (ngauss != ngaussVerif):
00097     print "the number of Gauss points does not match"
00098     print ngauss, " verif ", ngaussVerif
00099     pass
00100 
00101 if (interlacingType != interlacingTypeVerif):
00102     print "the interlacing type does not match"
00103     print interlacingType, " verif ", interlacingTypeVerif
00104     pass
00105 
00106 if (gaussLocName != gaussLocNameVerif):
00107     print "the Gauss Location name does not match"
00108     print gaussLocName, " verif ", gaussLocNameVerif
00109     pass
00110 
00111 if (lenrefCoo == lenrefCooVerif):
00112     print "refCoo verification -- length ",lenrefCoo
00113     for i in range(lenrefCoo):
00114         if (refCoo[i] != refCooVerif[i]):
00115             print " * ",i," ",refCoo[i], " --- ",refCooVerif[i]
00116 else:
00117     print "the array of referrence element coordinates does not match"
00118 
00119 if (lengsCoo == lengsCooVerif):
00120     print "gsCoo verification -- length ",lengsCoo
00121     for i in range(lengsCoo):
00122         if (gsCoo[i] != gsCooVerif[i]):
00123             print " * ",i," ",gsCoo[i], " --- ",gsCooVerif[i]
00124 else:
00125     print "the array of gauss points coordinates does not match"
00126 
00127 if (lenweight == lenweightVerif):
00128     print "weight verification -- length ",lenweight
00129     for i in range(lenweight):
00130         if (weight[i] != weightVerif[i]):
00131             print " * ",i," ",weight[i], " --- ",weightVerif[i]
00132 else:
00133     print "the array of gauss points weight does not match"
00134 
00135 print "seems to be OK"
00136 print ""
00137 print "END of the Pyhton script ..... Ctrl D to exit"