コード例 #1
0
ファイル: OneInletHelper.py プロジェクト: yieldthought/hemelb
    def __init__(self, proFile):
        # Configurable parameters
        self.MaxAllowedMachNumber = 0.05
        self.InletReynoldsNumber = 300.0
        self.MinRadiusVoxels = 5.0
        
        # Read the profile
        self.FileName = proFile
        self._profile = Profile()
        self._profile.LoadFromFile(proFile)
        # Proxy its iolets
        self.Iolets = [IoletProxy(iolet, self) for iolet in self._profile.Iolets]

        # Work out where to store the centrelines
        base = os.path.splitext(self.StlFile)[0]        
        self.CentreLineFile = base + '_centrelines.vtp'

        # Sort iolets -> inlets/outlets
        inlets = []
        outlets = []
        for io in self.Iolets:
            if isinstance(io._iolet, Inlet):
                inlets.append(io)
            else:
                outlets.append(io)
                pass
            continue
        # Require only one inlet!
        assert len(inlets) == 1
        self.Inlet = inlets[0]
        # Require 1 or more outlet
        assert len(outlets) > 0
        self.Outlets = outlets
        
        return
コード例 #2
0
ファイル: load.py プロジェクト: nicholasw-gc/hemelb
def temporary_profile(tmpdir, name):
    result = Profile()
    basename = tmpdir.join(name).strpath
    outGmyFileName = basename + '.gmy'
    outXmlFileName = basename + '.xml'
    result.OutputGeometryFile = outGmyFileName
    result.OutputXmlFile = outXmlFileName
    return result
コード例 #3
0
ファイル: fab.py プロジェクト: uschille/hemelb
def load_profile():
    with_profile(env.profile)
    from HemeLbSetupTool.Model.Profile import Profile
    p = Profile()
    p.LoadFromFile(
        os.path.expanduser(
            os.path.join(env.job_profile_path_local, env.profile) + '.pro'))
    return p
コード例 #4
0
def Upgrade(infilename, outfilename):
    oldProfile = LoadFakeProfile(infilename)
    UpdateProfileAttributes(oldProfile)

    # Create a new, genuine profile
    newPro = Profile()
    newPro.CloneFrom(oldProfile)

    newPro.Save(outfilename)
    return
コード例 #5
0
ファイル: Run.py プロジェクト: nicholasw-gc/hemelb
def Run(profileFile):
    """Process all the Inlets specified by profileFile, solving the Navier-
    Stokes equations for steady flow down an infinite channel with the cross
    section of the inlet. Writes the point ID and the fluid velocity at that 
    point, the velocity being such that the integral of the flow across the
    channel is unity.
    
    Currently output is written as vtkPolyData to files like
    "$GEOMETRYFILEBASENAME.inlet$ID.vtp"
    """
    # Load the profile
    profile = Profile()
    profile.LoadFromFile(profileFile)

    surfaceFile = profile.StlFile
    surfaceFileScale = profile.StlFileUnit.SizeInMetres

    print profile.OutputXmlFile
    ipFinder = GeometryInletPointFinder(profile.OutputXmlFile)
    inletPointIndices = ipFinder.GetInletData()
    if len(inletPointIndices) == 0:
        print "WARNING: no inletPointIndices found. This may mean that HemeLb is run with no inlets inside the simulation domain (e.g., the inlets defined in the xml file reside outside of the physical geometry)."

    intersectionFinder = SurfaceIntersectionFinder()
    intersectionFinder.SetFileName(surfaceFile)
    intersectionFinder.SetFileUnitLength(surfaceFileScale)

    for inletId, inlet in enumerate(io for io in profile.Iolets
                                    if isinstance(io, Inlet)):
        print inletId, len(profile.Iolets), len(inletPointIndices)
        inletPointPD = inletPointIndices[inletId]
        intersectionFinder.SetIolet(inlet)
        tesselator = Tesselator()
        tesselator.SetInlet(inlet)
        tesselator.SetEdgeConnection(intersectionFinder.GetOutputPort())
        tesselator.SetSitesConnection(inletPointPD.GetProducerPort())

        solver = PoiseuilleSolver()
        solver.SetInputConnection(tesselator.GetOutputPort())

        cellToPoint = vtk.vtkCellDataToPointData()
        cellToPoint.SetInputConnection(solver.GetOutputPort())
        cellToPoint.Update()
        #writer = vtk.vtkXMLPolyDataWriter()
        writer = vtk.vtkPolyDataWriter()
        writer.SetFileTypeToASCII()
        writer.SetInputConnection(cellToPoint.GetOutputPort())

        # print type(cellToPoint) #cellToPoint is of type vtkobject
        # print dir(cellToPoint)

        base, gmy = os.path.splitext(profile.OutputGeometryFile)
        writer.SetFileName(base + '.inlet%d.txt' % inletId)
        writer.Write()
        return base + '.inlet%d.txt' % inletId
コード例 #6
0
ファイル: Run.py プロジェクト: yieldthought/hemelb
def Run(profileFile):
    """Process all the Inlets specified by profileFile, solving the Navier-
    Stokes equations for steady flow down an infinite channel with the cross
    section of the inlet. Writes the point ID and the fluid velocity at that 
    point, the velocity being such that the integral of the flow across the
    channel is unity.
    
    Currently output is written as vtkPolyData to files like
    "$GEOMETRYFILEBASENAME.inlet$ID.vtp"
    """
    # Load the profile
    profile = Profile()
    profile.LoadFromFile(profileFile)

    surfaceFile = profile.StlFile
    surfaceFileScale = profile.StlFileUnit.SizeInMetres

    ipFinder = GeometryInletPointFinder(profile.OutputGeometryFile)
    inletPointIndices = ipFinder.GetInletData()

    intersectionFinder = SurfaceIntersectionFinder()
    intersectionFinder.SetFileName(surfaceFile)
    intersectionFinder.SetFileUnitLength(surfaceFileScale)

    for inletId, inlet in enumerate(io for io in profile.Iolets
                                    if isinstance(io, Inlet)):
        inletPointPD = inletPointIndices[inletId]
        intersectionFinder.SetIolet(inlet)
        tesselator = Tesselator()
        tesselator.SetInlet(inlet)
        tesselator.SetEdgeConnection(intersectionFinder.GetOutputPort())
        tesselator.SetSitesConnection(inletPointPD.GetProducerPort())

        solver = PoiseuilleSolver()
        solver.SetInputConnection(tesselator.GetOutputPort())

        cellToPoint = vtk.vtkCellDataToPointData()
        cellToPoint.SetInputConnection(solver.GetOutputPort())
        cellToPoint.Update()
        writer = vtk.vtkXMLPolyDataWriter()
        writer.SetInputConnection(cellToPoint.GetOutputPort())

        base, gmy = os.path.splitext(profile.OutputGeometryFile)
        writer.SetFileName(base + '.inlet%d.vtp' % inletId)
        writer.Write()
コード例 #7
0
    def test_regression(self, tmpdir):
        """Generate a gmy from a stored profile and check that the output is
        identical.
        """
        dataDir = os.path.join(os.path.split(__file__)[0], 'data')
        proFileName = os.path.join(dataDir, 'test.pro')

        p = Profile()
        p.LoadFromFile(proFileName)
        # Change the output to the tmpdir
        basename = tmpdir.join('test').strpath
        outGmyFileName = basename + '.gmy'
        outXmlFileName = basename + '.xml'
        p.OutputGeometryFile = outGmyFileName
        p.OutputXmlFile = outXmlFileName

        generator = OutputGeneration.PolyDataGenerator(p)
        generator.Execute()

        import filecmp
        assert filecmp.cmp(outGmyFileName, os.path.join(dataDir, 'test.gmy'))
        assert filecmp.cmp(outXmlFileName, os.path.join(dataDir, 'test.xml'))
コード例 #8
0
ファイル: App.py プロジェクト: nicholasw-gc/hemelb
    def OnInit(self):
        # Model
        self.profile = Profile()
        
        self.pipeline = Pipeline()
        
        # Controller
        self.controller = ProfileController(self.profile)
        self.controller.Pipeline = PipelineController(self.pipeline, self.controller)
        
        # View
        self.view = MainWindow(self.controller)

        if self.cmdLineProfileFile is not None:
            # Load the profile
            self.profile.LoadFromFile(self.cmdLineProfileFile)
            pass
        
        # override any keys that have been set on cmdline.
        self.profile.UpdateAttributesBasedOnCmdLineArgs(self.cmdLineArgs)
        
        self.SetTopWindow(self.view)
        return True