+# Copyright (C) 2016-2019 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
#import sys
#sys.path.append('/home/I60976/00_PROJETS/2015_INTEGRATION_ZCRACKS/zcracks_salome/zcracks')
import numpy, subprocess, sys
from os import remove, getpid, path, environ
-from output import message
+from .output import message
def calcCoordVectors(normalIN, directionIN):
V3TEMP=numpy.cross(normalIN,directionIN)
def testStrictRange(x, inf=0.0, sup=False):
test=False
- c1=(type(x)==list)
+ c1=(isinstance(x, list))
if c1:
c2=(len(x)==1)
if c2:
- c3=(type(x[0])==type(inf))
+ c3=(isinstance(x[0], type(inf)))
if c3:
c4=(x[0]>inf)
c5=True
def test3dVector(x):
test=False
- c1=(type(x)==list)
+ c1=(isinstance(x, list))
if c1:
c2=(len(x)==3)
if c2:
- c3=(type(x[0])==float)
- c4=(type(x[1])==float)
- c5=(type(x[2])==float)
+ c3=(isinstance(x[0], float))
+ c4=(isinstance(x[1], float))
+ c5=(isinstance(x[2], float))
if c3 and c4 and c5:
test=True
return(test)
def testRange(x, inf=0.0, sup=False):
test=False
- c1=(type(x)==list)
+ c1=(isinstance(x, list))
if c1:
c2=(len(x)==1)
if c2:
- c3=(type(x[0])==type(inf))
+ c3=(isinstance(x[0], type(inf)))
if c3:
c4=(x[0]>=inf)
c5=True
import salome
salome.salome_init()
- theStudy = salome.myStudy
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
- smesh = smeshBuilder.New(theStudy)
+ smesh = smeshBuilder.New()
Maillage = smesh.Mesh(geomObject)
if dim==3:
import SMESH, salome
#salome.salome_init()
- theStudy = salome.myStudy
from salome.smesh import smeshBuilder
- smesh = smeshBuilder.New(theStudy)
+ smesh = smeshBuilder.New()
([mesh], status) = smesh.CreateMeshesFromMED(meshFile)
-
+
+ if mesh.NbVolumes()>0:
+ case2D=False
+ mesh.Reorient2DBy3D( [ mesh ], mesh, 1 )
+ else:
+ case2D=True
+
mesh=cleanGroups(mesh)
# Node color status
if len(front)==0: crackOnly=False
if crackOnly:
- mesh.ExportMED(outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ mesh.ExportMED(outFile)
return('crack')
# Propagates color using elem connectivity
while ifChanged :
ifChanged=False
for elemId in elemList[0]:
- minColor=sys.maxint
- maxColor=-sys.maxint
+ minColor=sys.maxsize
+ maxColor=-sys.maxsize
for elemNodeId in mesh.GetElemNodes(elemId) :
nodeColor=colorList[elemNodeId-1]
if nodeColor<minColor : minColor=nodeColor
mesh.MakeGroupByIds('Extended_side%d' %n ,SMESH.EDGE,grElemList[2][n])
if outFile==None: outFile=meshFile
- mesh.ExportMED(outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ mesh.ExportMED(outFile)
return(True)
def getMaxAspectRatio(tmpdir):
logFile=path.join(tmpdir,'MESHING_OUTPUT')
- print logFile
+ print(logFile)
if not path.isfile(logFile): return(-1)
import re
return(float(maxAR))
-#def extendElsets(meshFile):
- #if not path.isfile(meshFile):
- #message('E','Mesh med file is not valid')
- #return(-1)
-
- #import SMESH, salome
- ##salome.salome_init()
- #theStudy = salome.myStudy
- #from salome.smesh import smeshBuilder
- #smesh = smeshBuilder.New(theStudy)
-
- #([mesh], status) = smesh.CreateMeshesFromMED(meshFile)
-
- ## Node color status
- #nodeList=mesh.GetNodesId()
- #colorList=[0]*len(nodeList)
-
- ## Init using SIDE0 SIDE1
- #for group in mesh.GetGroups():
- #if group.GetType()==SMESH.FACE :
- #color=0
- #if group.GetName()[0:4]=='SIDE0' :
- #color=1
- #elif group.GetName()[0:4]=='SIDE1' :
- #color=2
- #else : continue
- ## Get faces
- #faces=group.GetIDs()
- ## Set faces nodes to given color
- #for face_id in faces :
- #for face_node_id in mesh.GetElemNodes(face_id) :
- #colorList[face_node_id-1]=color
-
- ## Propagates color using elem connectivity
- ## Always propagates max color
- #volElemList=mesh.GetElementsByType(SMESH.VOLUME)
- #ifChanged=True
- #while ifChanged :
- #ifChanged=False
- #minColor=100
- #maxColor=0
- #for elemId in volElemList:
- #for elemNodeId in mesh.GetElemNodes(elemId) :
- #nodeColor=colorList[elemNodeId-1]
- #if nodeColor<minColor : minColor=nodeColor
- #if nodeColor>maxColor : maxColor=nodeColor
- #if minColor!=maxColor :
- #ifChanged = True
- #for elemNodeId in mesh.GetElemNodes(elemId) :
- #colorList[elemNodeId-1]=maxColor
-
- #velem0 = []
- #velem1 = []
- #for elemId in volElemList:
- #elemNodesId=mesh.GetElemNodes(elemId)
- #elemColor=colorList[elemNodesId[0]-1]
- #if(elemColor==1) : velem0.append(elemId)
- #if(elemColor==2) : velem1.append(elemId)
-
- #mesh.MakeGroupByIds('SIDE_co',SMESH.VOLUME,velem0)
- #mesh.MakeGroupByIds('SIDE_ext',SMESH.VOLUME,velem1)
-
- #surfElemList=mesh.GetElementsByType(SMESH.FACE)
- #selem0 = []
- #selem1 = []
- #nbelem0=0
- #nbelem1=0
-
- #for elemId in surfElemList:
- #elemNodesId=mesh.GetElemNodes(elemId)
- #elemColor=colorList[elemNodesId[0]-1]
- #if(elemColor==1) : selem0.append(elemId)
- #if(elemColor==2) : selem1.append(elemId)
-
- #mesh.MakeGroupByIds('SIDE_co',SMESH.FACE,selem0)
- #mesh.MakeGroupByIds('SIDE_ext',SMESH.FACE,selem1)
-
- #maxAR=0.
- #for elem in volElemList:
- #maxAR=max(mesh.GetAspectRatio(elem),maxAR)
- #for elem in surfElemList:
- #maxAR=max(mesh.GetAspectRatio(elem),maxAR)
-
- #mesh.ExportMED(meshFile, 0, SMESH.MED_V2_2, 1, None ,1)
- #return(maxAR)
def removeFromSessionPath(envVar, patern):
- if type(patern) is not list: patern=[patern]
- if type(envVar) is not list: envVar=[envVar]
+ if not isinstance(patern, list): patern=[patern]
+ if not isinstance(envVar, list): envVar=[envVar]
for env in envVar:
path=environ[env]