Exemple #1
0
    def changeWind(self, *args):
        '''Change in Mach, Re or nE (# element) by changing the solver
           and interpolating old solution'''
        for b in self.buttons.values():
            b.set_sensitive(False)
        self.terminateSolver()

        m = self.solver.mesh
        xt0, W0 = m.xt(), self.solver.soln
        freeStream0 = self.solver.freeStream(1)
        axesLimit = ravel(array(fig.axes[0].viewLim).T)

        v, t, b = adaptMesh(self.geom, m.v, m.t, m.b, self.nE, self.metric)
        e = extractEdges(v, t)
        self.vis = Visualize(v, t, e, self.fig, self.win, axesLimit)
        self.solver = chooseSolver(v, t, b, self.Mach, self.Re)
        #W0 = griddata(xt0, W0, self.solver.mesh.xt(), method='nearest')
        W0 = linNearGrid(xt0, W0, self.solver.mesh.xt())
        W0 += self.solver.freeStream(1) - freeStream0
        self.solver.integrate(1E-9, W0)
        self._soln_copy = self.solver.soln.copy()

        self.startSolver()
        self.buttons['MachDisp'].set_label('Mach = {0}'.format(self.Mach))
        self.buttons['ReDisp'].set_label('Re = {0}'.format(self.Re))
        self.buttons['NEDisp'].set_label('{0} cells'.format(self.nE))
        for b in self.buttons.values():
            b.set_sensitive(True)
Exemple #2
0
    def changeWind(self, *args):
        '''Change in Mach, Re or nE (# element) by changing the solver
           and interpolating old solution'''
        for b in self.buttons.values():
            b.set_sensitive(False)
        self.terminateSolver()

        xt0, W0 = self.xt, self.last_soln
        freeStream0 = freeStream(self.M0)
        axesLimit = ravel(array(fig.axes[0].viewLim).T)

        self.v, self.t, self.b = adaptMesh(self.geom, self.v, self.t, self.b,
                                           self.nE, self.metric)
        e = extractEdges(self.v, self.t)
        self.vis = Visualize(self.v, self.t, e, self.fig, self.win, axesLimit)
        self.xt = triCenters(self.v, self.t)

        nv = len(self.v)
        self.metric = zeros([nv, 2, 2])

        W0 = linNearGrid(xt0, W0, self.xt)
        W0 += freeStream(self.Mach) - freeStream0

        self.solver = SolverProcess(self.v, self.t, self.b, self.Mach, self.Re,
                                    self.data_queue, W0)

        self.startSolver()
        self.buttons['MachDisp'].set_label('Mach = {0}'.format(self.Mach))
        self.buttons['ReDisp'].set_label('Re = {0}'.format(self.Re))
        self.buttons['NEDisp'].set_label('{0} cells'.format(self.nE))
        for b in self.buttons.values():
            b.set_sensitive(True)
Exemple #3
0
class SimpleGui(object):
    def __init__(self, qlen = 2):
        self.fig = figure()
        self.fig.show()

        self.Mach = 0.3
        self.Re = 12500
        self.ne = 2500
        self.geom = rotate(loadtxt('../data/n0012c.dat'), 2./180*pi)

        self.data_queue = mp.Queue(qlen)
        v, t, b = initMesh(self.geom, self.ne )
        self.vis = Visualize(v, t, extractEdges(v, t), self.fig, None)

        self.solver_proc = SolverProcess(v, t, b, self.Mach, self.Re, self.data_queue)
        self.isRunning = True

        self.fig.canvas.mpl_connect('close_event', self.terminate )
        self.fig.canvas.mpl_connect('idle_event', self.run )

    def start(self):
        self.solver_proc.start()

    def run(self, event=None):

        if not self.data_queue.empty():
            try:
                new_data = self.data_queue.get(False)

                t = new_data.time
                soln = new_data.soln
                field = physical(soln, 'X-velocity')
                self.vis.update( 'MIT xWind, t = {0:.5f}'.format(t), field)

            except e:
                print 'no data available?'

        else:
            pass

        return True


    def terminate(self, close_event = None):
        self.solver_proc.terminate()
        self.isRunning = False
        self.fig.canvas.stop_event_loop_default()
Exemple #4
0
    def __init__(self, qlen = 2):
        self.fig = figure()
        self.fig.show()

        self.Mach = 0.3
        self.Re = 12500
        self.ne = 2500
        self.geom = rotate(loadtxt('../data/n0012c.dat'), 2./180*pi)

        self.data_queue = mp.Queue(qlen)
        v, t, b = initMesh(self.geom, self.ne )
        self.vis = Visualize(v, t, extractEdges(v, t), self.fig, None)

        self.solver_proc = SolverProcess(v, t, b, self.Mach, self.Re, self.data_queue)
        self.isRunning = True

        self.fig.canvas.mpl_connect('close_event', self.terminate )
        self.fig.canvas.mpl_connect('idle_event', self.run )
Exemple #5
0
 def changeGeom(self):
     'Change in geometry, new solver, new mesh, starting from freestream'
     self.terminateSolver()
     v, t, b = initMesh(self.geom, self.nE)
     print "v:{0}\nt:{1}\nb:{2}\ngeom:{3}".format(v.shape, t.shape, b.shape,
                                                  self.geom.shape)
     self.vis = Visualize(v, t, extractEdges(v, t), self.fig, self.win)
     self.solver = chooseSolver(v, t, b, self.Mach, self.Re)
     self.solver.integrate(1E-9, self.solver.freeStream())
     self._soln_copy = self.solver.soln.copy()
     self.startSolver()
Exemple #6
0
 def changeGeom(self):
     'Change in geometry, new solver, new mesh, starting from freestream'
     self.terminateSolver()
     self.v, self.t, self.b = initMesh(self.geom, self.nE)
     print "v:{0}\nt:{1}\nb:{2}\ngeom:{3}".format(self.v.shape,
                                                  self.t.shape,
                                                  self.b.shape,
                                                  self.geom.shape)
     self.vis = Visualize(self.v, self.t, extractEdges(self.v, self.t),
                          self.fig, self.win)
     self.solver = SolverProcess(self.v, self.t, self.b, self.Mach, self.Re,
                                 self.data_queue)
     self.xt = triCenters(self.v, self.t)
     nv = len(self.v)
     self.metric = zeros([nv, 2, 2])
     self.startSolver()