Exemplo n.º 1
0
    def step_results_usm3d(self):
        # minimum is 1
        nstep = 100

        assert self.out_filename is not None, self.out_filename
        flo_filename = self.out_filename
        dirname = os.path.dirname(flo_filename)
        if dirname == '':
            dirname = os.getcwd()
        basename = os.path.basename(flo_filename)
        base, ext = os.path.splitext(basename)
        #print "base=%r ext=%r" % (base, ext)
        if '_' in base:
            model_name, n = base.rsplit('_', 1)
            #print "model_name=%r n=%r" % (model_name, n)
            n = int(n)
            n_list = get_n_list(dirname, model_name)
            inn = n_list.index(n)
            if inn+nstep < len(n_list):
                nnew = n_list[inn+nstep]
            else:
                nnew = max(n_list)
                if nnew == n:
                    raise RuntimeError('%r is the last file' % self.out_filename)
            #print "inn=%r nnew=%r" % (inn, nnew)
            flo_filename = model_name + '_%s.flo' % nnew
        else:
            raise RuntimeError('The current file is must have the format of xxx_%%i.flo, not %r' % self.out_filename)
        #print "loading %r" % flo_filename
        self.load_usm3d_results(flo_filename, dirname)
        self.out_filename = os.path.join(dirname, flo_filename)

        print "done stepping..."
Exemplo n.º 2
0
    def on_reload_usm3d(self):
        """
        For USM3D, we dynamically load the latest CFD results time step,
        hich is really handy when you're running a job.
        """
        # minimum is 1
        nstep = 100

        if self.gui.out_filename is None:
            msg = 'usm3d_filename=%r must not be None\n' % self.gui.out_filename
            dir_gui = []
            for key in object_attributes(self.gui):
                try:
                    value = getattr(self.gui, key)
                except KeyError:
                    # self.edge_actor is a
                    if key not in ['edge_actor']:
                        self.gui.log.warning('key=%s is undefined...' % key)

                if isinstance(value, (integer_float_types, string_types)):
                    dir_gui.append(key)
            dir_gui.sort()
            msg += 'dir(gui) = [%s]' % ', '.join(dir_gui)
            raise RuntimeError(msg)
        flo_filename = self.gui.out_filename
        dirname = os.path.dirname(flo_filename)
        if dirname == '':
            dirname = os.getcwd()
        basename = os.path.basename(flo_filename)
        base = os.path.splitext(basename)[0]


        # box.flo -> box_100.flo
        if '_' in base:
            model_name, n = base.rsplit('_', 1)
            #print("model_name=%r n=%r" % (model_name, n))
            n = int(n)
            n_list = get_n_list(dirname, model_name)
            inn = n_list.index(n)
            if inn+nstep < len(n_list):
                nnew = n_list[inn+nstep]
            else:
                nnew = max(n_list)
                if nnew == n:
                    raise RuntimeError('%r is the last file' % self.gui.out_filename)
            #print("inn=%r nnew=%r" % (inn, nnew))
            flo_filename = model_name + '_%s.flo' % nnew
        else:
            flo_filename = self.gui.out_filename
            #msg = (
                #'The current file is must have the format of '
                #'xxx_%%i.flo, not %r' % self.out_filename)
            #raise RuntimeError(msg)
        #print("loading %r" % flo_filename)
        self.load_usm3d_results(flo_filename)
        self.gui.out_filename = os.path.join(dirname, flo_filename)
Exemplo n.º 3
0
    def on_reload_usm3d(self):
        """
        For USM3D, we dynamically load the latest CFD results time step,
        hich is really handy when you're running a job.
        """
        # minimum is 1
        nstep = 100

        assert self.parent.out_filename is not None, self.parent.out_filename
        flo_filename = self.parent.out_filename
        dirname = os.path.dirname(flo_filename)
        if dirname == '':
            dirname = os.getcwd()
        basename = os.path.basename(flo_filename)
        base = os.path.splitext(basename)[0]

        # box.flo -> box_100.flo
        if '_' in base:
            model_name, n = base.rsplit('_', 1)
            #print("model_name=%r n=%r" % (model_name, n))
            n = int(n)
            n_list = get_n_list(dirname, model_name)
            inn = n_list.index(n)
            if inn + nstep < len(n_list):
                nnew = n_list[inn + nstep]
            else:
                nnew = max(n_list)
                if nnew == n:
                    raise RuntimeError('%r is the last file' %
                                       self.parent.out_filename)
            #print("inn=%r nnew=%r" % (inn, nnew))
            flo_filename = model_name + '_%s.flo' % nnew
        else:
            flo_filename = self.parent.out_filename
            #msg = (
            #'The current file is must have the format of '
            #'xxx_%%i.flo, not %r' % self.out_filename)
            #raise RuntimeError(msg)
        #print("loading %r" % flo_filename)
        self.load_usm3d_results(flo_filename)
        self.parent.out_filename = os.path.join(dirname, flo_filename)
Exemplo n.º 4
0
# disable logging
info = self.show_info
debug = self.show_debug
command = self.show_command

self.show_info = False
self.show_debug = False
self.show_command = False

#===========================
# this could be dynamic...
model_name = 'bay'

dirname = os.getcwd()
n_list = get_n_list(dirname, model_name)  #[:20]

#n_list = [65495, 65475]
# take pictures every N steps
N = 440
nlist = [i for i in range(max(n_list)) if i % N == 0]
flo_filenames = get_flo_files_from_n(dirname,
                                     model_name,
                                     n_list,
                                     include_dirname_in_path=True)

self.on_load_geometry(infile_name=model_name + '.cogsg',
                      geometry_format='usm3d')
self.zoom(1.6)

for ni, flo_filename in zip(n_list, flo_filenames):