Package PyFoam :: Package RunDictionary :: Module MeshInformation
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.RunDictionary.MeshInformation

 1  """Gets information about the mesh of a case. Makes no attempt to manipulate 
 2  the mesh, because this is better left to the OpenFOAM-utilities""" 
 3   
 4  from SolutionDirectory import SolutionDirectory 
 5  from ListFile import ListFile 
 6  from PyFoam.Error import PyFoamException 
 7  from ParsedParameterFile import ParsedFileHeader 
 8   
 9  from os import path 
10  import re 
11   
12 -class MeshInformation:
13 """Reads Information about the mesh on demand""" 14
15 - def __init__(self,case,time="constant",processor=None):
16 """@param case: Path to the case-directory 17 @param time: Time for which the mesh should be looked at 18 @param processor: Name of the processor directory for decomposed cases""" 19 self.sol=SolutionDirectory(case,paraviewLink=False,archive=None) 20 self.time=time 21 self.processor=processor
22
23 - def nrOfFaces(self):
24 try: 25 return self.faces 26 except AttributeError: 27 faces=ListFile(self.sol.polyMeshDir(time=self.time,processor=self.processor),"faces") 28 self.faces=faces.getSize() 29 return self.faces
30
31 - def nrOfPoints(self):
32 try: 33 return self.points 34 except AttributeError: 35 points=ListFile(self.sol.polyMeshDir(time=self.time,processor=self.processor),"points") 36 self.points=points.getSize() 37 return self.points
38
39 - def nrOfCells(self):
40 try: 41 return self.cells 42 except: 43 try: 44 owner=ParsedFileHeader(path.join(self.sol.polyMeshDir(time=self.time,processor=self.processor),"owner")) 45 mat=re.compile('.+nCells: *([0-9]+) .+').match(owner["note"]) 46 self.cells=int(mat.group(1)) 47 return self.cells 48 except: 49 raise PyFoamException("Not Implemented")
50