1 # Copyright (C) 2007-2017 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 # Author : Anthony Geay (EDF R&D)
25 f=file("InterpKernelGaussCoords.cxx","r")
26 lines=[elt[:-1] for elt in f.readlines()[s1:s2]]
27 pat0=re.compile("void[\s]+GaussInfo\:\:([^\(]+)\([\s]*\)[\s]*$")
28 pat1=re.compile("[\s]*\{[\s]*$")
29 pat2=re.compile("[\s]+LOCAL_COORD_MACRO_BEGIN[\s]*\;[\s]*$")
30 m0=pat0.match(lines[0])
31 m1=pat1.match(lines[1])
32 m2=pat2.match(lines[2])
33 if (not m0) or (not m1) or (not m2):
34 raise Exception("Invalid first lines")
36 patEnd=re.compile("[\s]+LOCAL_COORD_MACRO_END[\s]*\;[\s]*$")
37 mEnd=patEnd.match(lines[-1])
39 raise Exception("Invalid end lines")
42 casePat=re.compile("[\s]+case[\s]+([\d]+)\:[\s]*$")
43 entries=[i_x for i_x in enumerate(lines[offsetLines:-1]) if casePat.match(i_x[1])]
47 raise Exception("Invalid lines nb !")
50 raise Exception("Ooops invalid dim !")
51 entries=[(i,int(casePat.match(elt).group(1))) for i,elt in entries]
52 assert({elt[1] for elt in entries} == set(range(nbPts)))
54 partEndEntries=re.compile("[\s]*break[\s]*\;[\s]*$")
55 zePat=re.compile("[\s]+coords\[([\d]+)\][\s]*=[\s]*([\-]?[\d]+[\.]?[\d]*)[\s]*\;[\s]*$")
56 zeTab=(nbPts*dim)*[None]
57 for lineId,ptId in entries:
58 endLine=lines[offsetLines+lineId+1+dim]
59 assert(partEndEntries.match(endLine))
61 curLine=lines[offsetLines+lineId+1+j]
62 m=zePat.match(curLine)
64 assert(int(m.group(1))==j)
65 zeTab[ptId*dim+j]=m.group(2)
68 assert(None not in zeTab)
70 assert(m0.group(1)[-len(patInit):]==patInit)
71 varName="%s_REF"%((m0.group(1)[:-len(patInit)]).upper())
72 print(("const double %s[%d]={%s};"%(varName,len(zeTab),", ".join(zeTab))))
73 for i in range(nbPts):
74 print((" case %d:"%(i)))
76 print((" coords[%d] = %s[%d];"%(j,varName,i*dim+j)))