Peclet = 5000 # vel/diffus
scheme='UDS'
dirichletBC = [[1, lambda b_: 1. - np.tanh(10.)],
               [2, lambda b_: 1. - np.tanh(10.)],
               [3, lambda b_: 1. - np.tanh(10.)],
               [4, lambda b_: 1. + np.tanh(10 * (2 * b_.center()[0] + 1.))],
               ]

print ("start", swatch.duration())
uGrid = solveFiniteVolume(grid, a=1./Peclet, f=f, vel=vB,
                          uBoundary=dirichletBC,
                          duBoundary=neumannBC,
                          scheme=scheme)
            

pg.showLater(1)
ax1,cb = show(grid)


drawStreams(ax1, grid, vC, coarseMesh=pg.createGrid(x=np.linspace(-1.0, 1.0, 41),
                                                    y=np.linspace(0.0, 1.0, 21)),
            )
print(swatch.duration())

#grid2, u2 = createFVPostProzessMesh(grid, u, dirichletBC)
show(grid, data=uGrid, 
     logScale=False, interpolate=1, tri=1,
     colorBar=True, axes=ax1)

#unstructured
boundary = []
示例#2
0
sourcePosB = [ 5.0, -4.0]

neumannBC = [[1, mixedBC], #left boundary
             [2, mixedBC], #right boundary
             ]

dirichletBC = [[4, 0]] #bottom boundary
k = 0.1

uFE = solver.solveFiniteElements(grid, a=a, b=k*k, f=pointSource,
                      duBoundary=neumannBC,
                      uBoundary=dirichletBC,
                      userData={'sourcePos': sourcePosA, 'k': k},
                      verbose=True)

pg.showLater(1)
ax1, cb = show(grid, uFE, 
               cMin=0, cMax=1, nLevs=10, colorBar=True)
drawMesh(ax1, grid)


f = pg.Vector(grid.cellCount(), 0)
f[grid.findCell(sourcePosA).id()]=1.0/grid.findCell(sourcePosA).size()

uFV = solveFiniteVolume(grid, a=a, b=k*k, f=f, 
                        duBoundary=neumannBC,
                        uBoundary=dirichletBC,
                        userData={'sourcePos': sourcePosA, 'k': k},
                        verbose=True)

#print('FVM:', swatch.duration(True))
示例#3
0
        np.savetxt(path + "/velocity-cov.vector", self.rayCoverage())
        np.savetxt(path + "/velocity-scov.vector", self.standardizedCoverage())

        self.mesh.addExportData("Velocity", self.velocity)
        self.mesh.addExportData("Coverage", self.rayCoverage())
        self.mesh.addExportData("S_Coverage", self.standardizedCoverage())
        self.mesh.exportVTK(path + "velocity")
        self.mesh.save(path + "velocity-mesh")
        self.pd.save(path + "velocity-pd")

        fig, ax = plt.subplots()
        self.showResult(ax=ax, cov=self.standardizedCoverage(), **kwargs)
        fig.set_size_inches(size)
        fig.savefig(path + "/velocity.pdf")

        return path, fig, ax


if __name__ == "__main__":
    datafile = sys.argv[1]
    ra = Refraction(datafile)
    print(ra)
    pg.showLater(True)
    ra.showData()
    ra.showVA()
    ra.makeMesh(depth=100)
    ra.showMesh()
    ra.run()
    ax, cbar = ra.showResult()
#    pg.showNow()