Exemplo n.º 1
0
def plot_radius(problem, state):
    import matplotlib.pyplot as plt

    from sfepy.postprocess.time_history import extract_time_history

    ths, ts = extract_time_history('unit_ball.h5', 'p e 0')

    p = ths['p'][0]
    L = 1.0 + ts.times[:p.shape[0]]

    L2 = 1.0 + nm.linspace(ts.times[0], ts.times[-1], 1000)
    p2 = get_balloon_pressure(L2, 1e-2, 1, 3e5, 3e4)

    plt.rcParams['lines.linewidth'] = 3
    plt.rcParams['text.fontsize'] = 16

    plt.plot(L2, p2, 'r', label='theory')
    plt.plot(L, p, 'b*', ms=12, label='FEM')

    plt.title('Mooney-Rivlin hyperelastic balloon inflation')
    plt.xlabel(r'relative stretch $r/r_0$')
    plt.ylabel(r'pressure $p$')

    plt.legend(loc='best')

    fig = plt.gcf()
    fig.savefig('balloon_pressure_stretch.pdf')

    plt.show()
Exemplo n.º 2
0
def plot_radius(problem, state):
    import matplotlib.pyplot as plt

    from sfepy.postprocess.time_history import extract_time_history

    ths, ts = extract_time_history('unit_ball.h5', 'p e 0')

    p = ths['p'][0]
    L = 1.0 + ts.times[:p.shape[0]]

    L2 = 1.0 + nm.linspace(ts.times[0], ts.times[-1], 1000)
    p2 = get_balloon_pressure(L2, 1e-2, 1, 3e5, 3e4)

    plt.rcParams['lines.linewidth'] = 3
    plt.rcParams['text.fontsize'] = 16

    plt.plot(L2, p2, 'r', label='theory')
    plt.plot(L, p, 'b*', ms=12, label='FEM')

    plt.title('Mooney-Rivlin hyperelastic balloon inflation')
    plt.xlabel(r'relative stretch $r/r_0$')
    plt.ylabel(r'pressure $p$')

    plt.legend(loc='best')

    fig = plt.gcf()
    fig.savefig('balloon_pressure_stretch.pdf')

    plt.show()
Exemplo n.º 3
0
def main():
    """
    Plot the load, displacement, strain and stresses w.r.t. time.
    """
    from argparse import ArgumentParser, RawDescriptionHelpFormatter
    import matplotlib.pyplot as plt

    import sfepy.postprocess.time_history as th

    msgs = {
        'node': 'plot displacements in given node [default: %(default)s]',
        'element': 'plot tensors in given element [default: %(default)s]',
    }

    parser = ArgumentParser(description=__doc__,
                            formatter_class=RawDescriptionHelpFormatter)
    parser.add_argument(metavar='OUTPUT_FILE',
                        dest='output_file',
                        help='output file in HDF5 format')
    parser.add_argument('-n',
                        '--node',
                        type=int,
                        metavar='ii',
                        action='store',
                        dest='node',
                        default=512,
                        help=msgs['node'])
    parser.add_argument('-e',
                        '--element',
                        type=int,
                        metavar='ii',
                        action='store',
                        dest='element',
                        default=299,
                        help=msgs['element'])
    options = parser.parse_args()

    filename = options.output_file

    tensor_names = [
        'cauchy_strain', 'cauchy_stress', 'viscous_stress', 'total_stress'
    ]
    extract = ('u n %d, ' % options.node) \
              + ', '.join('%s e %d' % (name, options.element)
                          for name in tensor_names)
    ths, ts = th.extract_time_history(filename, extract)

    load = [
        linear_tension(ts, nm.array([0]), mode='qp',
                       verbose=False)['val'].squeeze() for ii in ts
    ]
    load = nm.array(load)

    normalized_kernel = kernel[:, 0, 0] / kernel[0, 0, 0]

    plt.figure(1, figsize=(8, 10))
    plt.subplots_adjust(hspace=0.3,
                        top=0.95,
                        bottom=0.05,
                        left=0.07,
                        right=0.95)

    plt.subplot(311)
    plt.plot(times, normalized_kernel, lw=3)
    plt.title('fading memory decay')
    plt.xlabel('time')

    plt.subplot(312)
    plt.plot(ts.times, load, lw=3)
    plt.title('load')
    plt.xlabel('time')

    displacements = ths['u'][options.node]

    plt.subplot(313)
    plt.plot(ts.times, displacements, lw=3)
    plt.title('displacement components, node %d' % options.node)
    plt.xlabel('time')

    plt.figure(2, figsize=(8, 10))
    plt.subplots_adjust(hspace=0.35,
                        top=0.95,
                        bottom=0.05,
                        left=0.07,
                        right=0.95)

    for ii, tensor_name in enumerate(tensor_names):
        tensor = ths[tensor_name][options.element]

        plt.subplot(411 + ii)
        plt.plot(ts.times, tensor, lw=3)
        plt.title('%s components, element %d' % (tensor_name, options.element))
        plt.xlabel('time')

    plt.show()
Exemplo n.º 4
0
def main():
    """
    Plot the load, displacement, strain and stresses w.r.t. time.
    """
    from argparse import ArgumentParser, RawDescriptionHelpFormatter
    import matplotlib.pyplot as plt

    import sfepy.postprocess.time_history as th

    msgs = {
        'node': 'plot displacements in given node [default: %(default)s]',
        'element': 'plot tensors in given element [default: %(default)s]',
    }

    parser = ArgumentParser(description=__doc__,
                            formatter_class=RawDescriptionHelpFormatter)
    parser.add_argument(metavar='OUTPUT_FILE', dest='output_file',
                        help='output file in HDF5 format')
    parser.add_argument('-n', '--node', type=int, metavar='ii',
                        action='store', dest='node',
                        default=512, help=msgs['node'])
    parser.add_argument('-e', '--element', type=int, metavar='ii',
                        action='store', dest='element',
                        default=299, help=msgs['element'])
    options = parser.parse_args()

    filename = options.output_file

    tensor_names = ['cauchy_strain',
                    'cauchy_stress', 'viscous_stress', 'total_stress']
    extract = ('u n %d, ' % options.node) \
              + ', '.join('%s e %d' % (name, options.element)
                          for name in tensor_names)
    ths, ts = th.extract_time_history(filename, extract)

    load = [linear_tension(ts, nm.array([0]),
                           mode='qp', verbose=False)['val'].squeeze()
            for ii in ts]
    load = nm.array(load)

    normalized_kernel = kernel[:, 0, 0] / kernel[0, 0, 0]

    plt.figure(1, figsize=(8, 10))
    plt.subplots_adjust(hspace=0.3,
                        top=0.95, bottom=0.05, left=0.07, right=0.95)

    plt.subplot(311)
    plt.plot(times, normalized_kernel, lw=3)
    plt.title('fading memory decay')
    plt.xlabel('time')

    plt.subplot(312)
    plt.plot(ts.times, load, lw=3)
    plt.title('load')
    plt.xlabel('time')

    displacements = ths['u'][options.node]

    plt.subplot(313)
    plt.plot(ts.times, displacements, lw=3)
    plt.title('displacement components, node %d' % options.node)
    plt.xlabel('time')

    plt.figure(2, figsize=(8, 10))
    plt.subplots_adjust(hspace=0.35,
                        top=0.95, bottom=0.05, left=0.07, right=0.95)

    for ii, tensor_name in enumerate(tensor_names):
        tensor = ths[tensor_name][options.element]

        plt.subplot(411 + ii)
        plt.plot(ts.times, tensor, lw=3)
        plt.title('%s components, element %d' % (tensor_name, options.element))
        plt.xlabel('time')

    plt.show()
Exemplo n.º 5
0
def main():
    parser = OptionParser(usage=usage, version="%prog " + sfepy.__version__)
    parser.add_option('-o',
                      '',
                      metavar='filename',
                      action='store',
                      dest='output_filename_trunk',
                      default=None,
                      help=help['filename'])
    parser.add_option('-d',
                      '--dump',
                      action='store_true',
                      dest='dump',
                      default=False,
                      help=help['dump'])
    parser.add_option('',
                      '--same-dir',
                      action='store_true',
                      dest='same_dir',
                      default=False,
                      help=help['same_dir'])
    parser.add_option('-l',
                      '--linearization',
                      metavar='options',
                      action='store',
                      dest='linearization',
                      default=None,
                      help=help['linearization'])
    parser.add_option('',
                      '--times',
                      action='store_true',
                      dest='times',
                      default=False,
                      help=help['times'])
    parser.add_option('-f',
                      '--from',
                      type=int,
                      metavar='ii',
                      action='store',
                      dest='step_from',
                      default=0,
                      help=help['from'])
    parser.add_option('-t',
                      '--to',
                      type=int,
                      metavar='ii',
                      action='store',
                      dest='step_to',
                      default=None,
                      help=help['to'])
    parser.add_option('-s',
                      '--step',
                      type=int,
                      metavar='ii',
                      action='store',
                      dest='step_by',
                      default=1,
                      help=help['step'])
    parser.add_option('-e',
                      '--extract',
                      metavar='list',
                      action='store',
                      dest='extract',
                      default=None,
                      help=help['extract'])
    parser.add_option('-a',
                      '--average',
                      action='store_true',
                      dest='average',
                      default=False,
                      help=help['average'])

    (options, args) = parser.parse_args()

    nargs = len(args)
    if nargs == 1:
        filename_results = args[0]
        linearize = False

    elif nargs == 2:
        filename_in, filename_results = args
        linearize = True
        options.dump = True

    else:
        parser.print_help()
        return

    if options.times:
        steps, times, nts, dts = th.extract_times(filename_results)
        for ii, time in enumerate(times):
            step = steps[ii]
            print '%d %e %e %e' % (step, time, nts[ii], dts[ii])

    if options.dump:
        trunk = get_default(options.output_filename_trunk,
                            get_trunk(filename_results))
        if options.same_dir:
            trunk = os.path.join(os.path.dirname(filename_results),
                                 os.path.basename(trunk))

        args = {}
        if linearize:
            problem = create_problem(filename_in)

            linearization = Struct(kind='adaptive',
                                   min_level=0,
                                   max_level=2,
                                   eps=1e-2)
            aux = problem.conf.options.get('linearization', None)
            linearization.update(aux)

            if options.linearization is not None:
                aux = parse_linearization(options.linearization)
                linearization.update(aux)

            args.update({
                'fields': problem.fields,
                'linearization': linearization
            })

        if options.step_to is None:
            args.update({'step0': options.step_from})

        else:
            args.update({
                'steps':
                nm.arange(options.step_from,
                          options.step_to + 1,
                          options.step_by,
                          dtype=nm.int)
            })

        th.dump_to_vtk(filename_results, output_filename_trunk=trunk, **args)

    if options.extract:
        ths, ts = th.extract_time_history(filename_results, options.extract)

        if options.average:
            ths = th.average_vertex_var_in_cells(ths)

        if options.output_filename_trunk:
            th.save_time_history(ths, ts,
                                 options.output_filename_trunk + '.h5')

        else:
            print dict_to_struct(ths, flag=(1, 1, 1)).str_all()
Exemplo n.º 6
0
def main():
    """
    Plot the load, displacement, strain and stresses w.r.t. time.
    """
    from optparse import OptionParser
    import matplotlib.pyplot as plt

    import sfepy.postprocess.time_history as th

    usage = """%prog <output file in HDF5 format>"""

    msgs = {
        "node": "plot displacements in given node [default: %default]",
        "element": "plot tensors in given element [default: %default]",
    }

    parser = OptionParser(usage=usage)
    parser.add_option(
        "-n", "--node", type=int, metavar="ii", action="store", dest="node", default=512, help=msgs["node"]
    )
    parser.add_option(
        "-e", "--element", type=int, metavar="ii", action="store", dest="element", default=299, help=msgs["element"]
    )
    options, args = parser.parse_args()

    if len(args) == 1:
        filename = args[0]

    else:
        parser.print_help()
        return

    tensor_names = ["cauchy_strain", "cauchy_stress", "viscous_stress", "total_stress"]
    extract = ("u n %d, " % options.node) + ", ".join("%s e %d" % (name, options.element) for name in tensor_names)
    ths, ts = th.extract_time_history(filename, extract)

    load = [linear_tension(ts, nm.array([0]), mode="qp", verbose=False)["val"].squeeze() for ii in ts]
    load = nm.array(load)

    normalized_kernel = kernel[:, 0, 0] / kernel[0, 0, 0]

    plt.figure(1, figsize=(8, 10))
    plt.subplots_adjust(hspace=0.3, top=0.95, bottom=0.05, left=0.07, right=0.95)

    plt.subplot(311)
    plt.plot(times, normalized_kernel, lw=3)
    plt.title("fading memory decay")
    plt.xlabel("time")

    plt.subplot(312)
    plt.plot(ts.times, load, lw=3)
    plt.title("load")
    plt.xlabel("time")

    displacements = ths["u"][options.node]

    plt.subplot(313)
    plt.plot(ts.times, displacements, lw=3)
    plt.title("displacement components, node %d" % options.node)
    plt.xlabel("time")

    plt.figure(2, figsize=(8, 10))
    plt.subplots_adjust(hspace=0.35, top=0.95, bottom=0.05, left=0.07, right=0.95)

    for ii, tensor_name in enumerate(tensor_names):
        tensor = ths[tensor_name][options.element]

        plt.subplot(411 + ii)
        plt.plot(ts.times, tensor, lw=3)
        plt.title("%s components, element %d" % (tensor_name, options.element))
        plt.xlabel("time")

    plt.show()
Exemplo n.º 7
0
def main():
    parser = OptionParser(usage=usage, version="%prog " + sfepy.__version__)
    parser.add_option('-o', '', metavar='filename',
                      action='store', dest='output_filename_trunk',
                      default=None, help=help['filename'])
    parser.add_option('-d', '--dump', action='store_true', dest='dump',
                       default=False, help=help['dump'])
    parser.add_option('', '--same-dir', action='store_true', dest='same_dir',
                      default=False, help=help['same_dir'])
    parser.add_option('-l', '--linearization', metavar='options',
                      action='store', dest='linearization',
                      default=None, help=help['linearization'])
    parser.add_option('', '--times', action='store_true', dest='times',
                      default=False, help=help['times'])
    parser.add_option('-f', '--from', type=int, metavar='ii',
                      action='store', dest='step_from',
                      default=0, help=help['from'])
    parser.add_option('-t', '--to', type=int, metavar='ii',
                      action='store', dest='step_to',
                      default=None, help=help['to'])
    parser.add_option('-s', '--step', type=int, metavar='ii',
                      action='store', dest='step_by',
                      default=1, help=help['step'])
    parser.add_option('-e', '--extract', metavar='list',
                      action='store', dest='extract',
                      default=None, help=help['extract'])
    parser.add_option('-a', '--average', action='store_true', dest='average',
                      default=False, help=help['average'])

    (options, args) = parser.parse_args()

    nargs = len(args)
    if nargs == 1:
        filename_results = args[0]
        linearize = False

    elif nargs == 2:
        filename_in, filename_results = args
        linearize = True
        options.dump = True

    else:
        parser.print_help()
        return

    if options.times:
        steps, times, nts, dts = th.extract_times(filename_results)
        for ii, time in enumerate(times):
            step = steps[ii]
            print('%d %e %e %e' % (step, time, nts[ii], dts[ii]))

    if options.dump:
        trunk = get_default(options.output_filename_trunk,
                            get_trunk(filename_results))
        if options.same_dir:
            trunk = os.path.join(os.path.dirname(filename_results),
                                 os.path.basename(trunk))

        args = {}
        if linearize:
            problem = create_problem(filename_in)

            linearization = Struct(kind='adaptive', min_level=0,
                                   max_level=2, eps=1e-2)
            aux = problem.conf.options.get('linearization', None)
            linearization.update(aux)

            if options.linearization is not None:
                aux = parse_linearization(options.linearization)
                linearization.update(aux)

            args.update({'fields' : problem.fields,
                         'linearization' : linearization})

        if options.step_to is None:
            args.update({'step0' : options.step_from})

        else:
            args.update({'steps' : nm.arange(options.step_from,
                                             options.step_to + 1,
                                             options.step_by, dtype=nm.int)})

        th.dump_to_vtk(filename_results, output_filename_trunk=trunk, **args)

    if options.extract:
        ths, ts = th.extract_time_history(filename_results, options.extract)

        if options.average:
            ths = th.average_vertex_var_in_cells(ths)

        if options.output_filename_trunk:
            th.save_time_history(ths, ts, options.output_filename_trunk + '.h5')

        else:
            print(dict_to_struct(ths, flag=(1, 1, 1)).str_all())
Exemplo n.º 8
0
def main():
    parser = ArgumentParser(description=__doc__,
                            formatter_class=RawDescriptionHelpFormatter)
    parser.add_argument('--version',
                        action='version',
                        version='%(prog)s ' + sfepy.__version__)
    parser.add_argument('--debug',
                        action='store_true',
                        dest='debug',
                        default=False,
                        help=helps['debug'])
    parser.add_argument('-o',
                        metavar='filename',
                        action='store',
                        dest='output_filename_trunk',
                        default=None,
                        help=helps['filename'])
    parser.add_argument('-d',
                        '--dump',
                        action='store_true',
                        dest='dump',
                        default=False,
                        help=helps['dump'])
    parser.add_argument('--same-dir',
                        action='store_true',
                        dest='same_dir',
                        default=False,
                        help=helps['same_dir'])
    parser.add_argument('-l',
                        '--linearization',
                        metavar='options',
                        action='store',
                        dest='linearization',
                        default=None,
                        help=helps['linearization'])
    parser.add_argument('--times',
                        action='store_true',
                        dest='times',
                        default=False,
                        help=helps['times'])
    parser.add_argument('-f',
                        '--from',
                        type=int,
                        metavar='ii',
                        action='store',
                        dest='step_from',
                        default=0,
                        help=helps['from'])
    parser.add_argument('-t',
                        '--to',
                        type=int,
                        metavar='ii',
                        action='store',
                        dest='step_to',
                        default=None,
                        help=helps['to'])
    parser.add_argument('-s',
                        '--step',
                        type=int,
                        metavar='ii',
                        action='store',
                        dest='step_by',
                        default=1,
                        help=helps['step'])
    parser.add_argument('-e',
                        '--extract',
                        metavar='list',
                        action='store',
                        dest='extract',
                        default=None,
                        help=helps['extract'])
    parser.add_argument('-a',
                        '--average',
                        action='store_true',
                        dest='average',
                        default=False,
                        help=helps['average'])
    parser.add_argument('input_file', nargs='?', default=None)
    parser.add_argument('results_file')
    options = parser.parse_args()

    if options.debug:
        from sfepy.base.base import debug_on_error
        debug_on_error()

    filename_in = options.input_file
    filename_results = options.results_file

    if filename_in is None:
        linearize = False
    else:
        linearize = True
        options.dump = True

    if options.times:
        steps, times, nts, dts = th.extract_times(filename_results)
        for ii, time in enumerate(times):
            step = steps[ii]
            print('%d %e %e %e' % (step, time, nts[ii], dts[ii]))

    if options.dump:
        trunk = get_default(options.output_filename_trunk,
                            get_trunk(filename_results))
        if options.same_dir:
            trunk = os.path.join(os.path.dirname(filename_results),
                                 os.path.basename(trunk))

        args = {}
        if linearize:
            problem = create_problem(filename_in)

            linearization = Struct(kind='adaptive',
                                   min_level=0,
                                   max_level=2,
                                   eps=1e-2)
            aux = problem.conf.options.get('linearization', None)
            linearization.update(aux)

            if options.linearization is not None:
                aux = parse_linearization(options.linearization)
                linearization.update(aux)

            args.update({
                'fields': problem.fields,
                'linearization': linearization
            })

        if options.step_to is None:
            args.update({'step0': options.step_from})

        else:
            args.update({
                'steps':
                nm.arange(options.step_from,
                          options.step_to + 1,
                          options.step_by,
                          dtype=nm.int)
            })

        th.dump_to_vtk(filename_results, output_filename_trunk=trunk, **args)

    if options.extract:
        ths, ts = th.extract_time_history(filename_results, options.extract)

        if options.average:
            ths = th.average_vertex_var_in_cells(ths)

        if options.output_filename_trunk:
            th.save_time_history(ths, ts,
                                 options.output_filename_trunk + '.h5')

        else:
            print(dict_to_struct(ths, flag=(1, 1, 1)).str_all())
Exemplo n.º 9
0
def main():
    parser = ArgumentParser(description=__doc__, formatter_class=RawDescriptionHelpFormatter)
    parser.add_argument("--version", action="version", version="%(prog)s " + sfepy.__version__)
    parser.add_argument("--debug", action="store_true", dest="debug", default=False, help=helps["debug"])
    parser.add_argument(
        "-o", metavar="filename", action="store", dest="output_filename_trunk", default=None, help=helps["filename"]
    )
    parser.add_argument("-d", "--dump", action="store_true", dest="dump", default=False, help=helps["dump"])
    parser.add_argument("--same-dir", action="store_true", dest="same_dir", default=False, help=helps["same_dir"])
    parser.add_argument(
        "-l",
        "--linearization",
        metavar="options",
        action="store",
        dest="linearization",
        default=None,
        help=helps["linearization"],
    )
    parser.add_argument("--times", action="store_true", dest="times", default=False, help=helps["times"])
    parser.add_argument(
        "-f", "--from", type=int, metavar="ii", action="store", dest="step_from", default=0, help=helps["from"]
    )
    parser.add_argument(
        "-t", "--to", type=int, metavar="ii", action="store", dest="step_to", default=None, help=helps["to"]
    )
    parser.add_argument(
        "-s", "--step", type=int, metavar="ii", action="store", dest="step_by", default=1, help=helps["step"]
    )
    parser.add_argument(
        "-e", "--extract", metavar="list", action="store", dest="extract", default=None, help=helps["extract"]
    )
    parser.add_argument("-a", "--average", action="store_true", dest="average", default=False, help=helps["average"])
    parser.add_argument("input_file", nargs="?", default=None)
    parser.add_argument("results_file")
    options = parser.parse_args()

    if options.debug:
        from sfepy.base.base import debug_on_error

        debug_on_error()

    filename_in = options.input_file
    filename_results = options.results_file

    if filename_in is None:
        linearize = False
    else:
        linearize = True
        options.dump = True

    if options.times:
        steps, times, nts, dts = th.extract_times(filename_results)
        for ii, time in enumerate(times):
            step = steps[ii]
            print("%d %e %e %e" % (step, time, nts[ii], dts[ii]))

    if options.dump:
        trunk = get_default(options.output_filename_trunk, get_trunk(filename_results))
        if options.same_dir:
            trunk = os.path.join(os.path.dirname(filename_results), os.path.basename(trunk))

        args = {}
        if linearize:
            problem = create_problem(filename_in)

            linearization = Struct(kind="adaptive", min_level=0, max_level=2, eps=1e-2)
            aux = problem.conf.options.get("linearization", None)
            linearization.update(aux)

            if options.linearization is not None:
                aux = parse_linearization(options.linearization)
                linearization.update(aux)

            args.update({"fields": problem.fields, "linearization": linearization})

        if options.step_to is None:
            args.update({"step0": options.step_from})

        else:
            args.update({"steps": nm.arange(options.step_from, options.step_to + 1, options.step_by, dtype=nm.int)})

        th.dump_to_vtk(filename_results, output_filename_trunk=trunk, **args)

    if options.extract:
        ths, ts = th.extract_time_history(filename_results, options.extract)

        if options.average:
            ths = th.average_vertex_var_in_cells(ths)

        if options.output_filename_trunk:
            th.save_time_history(ths, ts, options.output_filename_trunk + ".h5")

        else:
            print(dict_to_struct(ths, flag=(1, 1, 1)).str_all())
Exemplo n.º 10
0
def main():
    parser = OptionParser(usage = usage, version = "%prog " + sfepy.__version__)
    parser.add_option( "-o", "", metavar = 'filename',
                       action = "store", dest = "output_filename_trunk",
                       default = None, help = help['filename'] )
    parser.add_option( "-d", "--dump",
                       action = "store_true", dest = "dump",
                       default = False, help = help['dump'] )
    parser.add_option( "", "--same-dir",
                       action = "store_true", dest = "same_dir",
                       default = False, help = help['same_dir'] )
    parser.add_option( "-f", "--from", type = int, metavar = 'ii',
                       action = "store", dest = "step_from",
                       default = 0, help = help['from'] )
    parser.add_option( "-t", "--to", type = int, metavar = 'ii',
                       action = "store", dest = "step_to",
                       default = None, help = help['to'] )
    parser.add_option( "-s", "--step", type = int, metavar = 'ii',
                       action = "store", dest = "step_by",
                       default = 1, help = help['step'] )
    parser.add_option( "-e", "--extract", metavar = 'list',
                       action = "store", dest = "extract",
                       default = None, help = help['extract'] )
    parser.add_option( "-a", "--average",
                       action = "store_true", dest = "average",
                       default = False, help = help['average'] )

    (options, args) = parser.parse_args()

    if (len( args ) == 1):
        filename_in = args[0];
    else:
        parser.print_help(),
        return

    if options.dump:
        trunk = get_default(options.output_filename_trunk,
                            get_trunk(filename_in))
        if options.same_dir:
            trunk = os.path.join(os.path.dirname(filename_in),
                                 os.path.basename(trunk))
        
        if options.step_to is None:
            dump_to_vtk(filename_in,
                        output_filename_trunk=trunk,
                        step0=options.step_from)

        else:
            dump_to_vtk(filename_in,
                        output_filename_trunk=trunk,
                        steps=nm.arange(options.step_from,
                                        options.step_to + 1,
                                        options.step_by, dtype=nm.int))

    if options.extract:
        ths, ts = extract_time_history(filename_in, options.extract)
##         print ths

        if options.average:
            ths = average_vertex_var_in_cells( ths )
##             print ths

        if options.output_filename_trunk:
            save_time_history(ths, ts, options.output_filename_trunk + '.h5')

        else:
            print dict_to_struct(ths, flag=(1, 1, 1)).str_all()