Esempio n. 1
0
def main():
    # if multi_mpi.cpu_count() < 2:
    #     raise ValueError('MPI mode - the number of nodes is less then 2!')

    if multi_mpi.mpi_rank == multi_mpi.mpi_master:
        # MPI master node - solve problem at macro scale
        parser = ArgumentParser(description=__doc__,
                                formatter_class=RawDescriptionHelpFormatter)
        parser.add_argument('--debug',
                            action='store_true', dest='debug',
                            default=False, help=helps['debug'])
        parser.add_argument('--debug_mpi',
                            action='store_true', dest='debug_mpi',
                            default=False, help=helps['debug_mpi'])
        parser.add_argument('-c', '--conf', metavar='"key : value, ..."',
                            action='store', dest='conf', type=str,
                            default=None, help=helps['conf'])
        parser.add_argument('-O', '--options', metavar='"key : value, ..."',
                            action='store', dest='app_options', type=str,
                            default=None, help=helps['options'])
        parser.add_argument('-d', '--define', metavar='"key : value, ..."',
                            action='store', dest='define_args', type=str,
                            default=None, help=helps['define'])
        parser.add_argument('-o', metavar='filename',
                            action='store', dest='output_filename_trunk',
                            default=None, help=helps['filename'])
        parser.add_argument('--format', metavar='format',
                            action='store', dest='output_format',
                            default=None, help=helps['output_format'])
        parser.add_argument('--log', metavar='file',
                            action='store', dest='log',
                            default=None, help=helps['log'])
        parser.add_argument('-q', '--quiet',
                            action='store_true', dest='quiet',
                            default=False, help=helps['quiet'])
        group = parser.add_mutually_exclusive_group(required=True)
        group.add_argument('filename_in', nargs='?')
        options = parser.parse_args()

        for k in ['save_ebc', 'save_ebc_nodes', 'save_regions',
                  'save_regions_as_groups', 'save_field_meshes', 'solve_not']:
            setattr(options, k, False)

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

        if options.debug_mpi:
            multi_mpi.set_logging_level('debug')

        filename_in = options.filename_in
        output.set_output(filename=options.log,
                          quiet=options.quiet,
                          combined=options.log is not None)

        required, other = get_standard_keywords()
        conf = ProblemConf.from_file_and_options(filename_in, options,
            required, other, define_args=options.define_args)

        opts = conf.options
        nslaves = multi_mpi.cpu_count() - 1
        opts.n_mpi_homog_slaves = nslaves
        output_prefix = opts.get('output_prefix', 'sfepy:')

        app = PDESolverApp(conf, options, output_prefix)
        if hasattr(opts, 'parametric_hook'):  # Parametric study.
            parametric_hook = conf.get_function(opts.parametric_hook)
            app.parametrize(parametric_hook)
        app()

        multi_mpi.master_send_task('finalize', None)
    else:
        # MPI slave mode - calculate homogenized coefficients
        homogen_app = None
        done = False
        rank = multi_mpi.mpi_rank
        while not done:
            task, data = multi_mpi.slave_get_task('main slave loop')

            if task == 'init':  # data: micro_file, n_micro
                output.set_output(filename='homog_app_mpi_%d.log' % rank,
                                  quiet=True)
                micro_file, n_micro = data[:2]
                required, other = get_standard_keywords()
                required.remove('equations')
                conf = ProblemConf.from_file(micro_file, required, other,
                                             verbose=False)
                options = Struct(output_filename_trunk=None)
                homogen_app = HomogenizationApp(conf, options, 'micro:',
                                                n_micro=n_micro,
                                                update_micro_coors=True)
            elif task == 'calculate':  # data: rel_def_grad, ts, iteration
                rel_def_grad, ts, iteration = data[:3]
                homogen_app.setup_macro_deformation(rel_def_grad)
                homogen_app(ret_all=True, itime=ts.step, iiter=iteration)
            elif task == 'finalize':
                done = True
Esempio n. 2
0
                               quadratic=False, tetgenpath=tetgen_path)
                m = Mesh.from_file("tmp/t.1.node")
                m.write(mesh_filename, io="auto")
            output("...mesh written to %s" % mesh_filename)
            return

        else:
            parser.print_help()
            return

    else:
        parser.print_help()
        return

    required, other = get_standard_keywords()
    conf = ProblemConf.from_file_and_options(filename_in, options,
                                             required, other)

    if options.mesh:
        from sfepy.fem.mesh_generators import gen_mesh_from_string

        conf.filename_mesh = gen_mesh_from_string(options.mesh,
                                                  options.mesh_dir)

    elif auto_mesh_name and not sfepy.in_source_tree:
        conf.filename_mesh = mesh_filename
        conf.options.absolute_mesh_path = True

    app = SchroedingerApp(conf, options, 'schroedinger:')
    opts = conf.options
    if hasattr(opts, 'parametric_hook'): # Parametric study.
        parametric_hook = conf.get_function(opts.parametric_hook)
Esempio n. 3
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('-c', '--conf', metavar='"key : value, ..."',
                        action='store', dest='conf', type=str,
                        default=None, help= helps['conf'])
    parser.add_argument('-O', '--options', metavar='"key : value, ..."',
                        action='store', dest='app_options', type=str,
                        default=None, help=helps['options'])
    parser.add_argument('-o', metavar='filename',
                        action='store', dest='output_filename_trunk',
                        default=None, help=helps['filename'])
    group = parser.add_mutually_exclusive_group()
    group.add_argument('--oscillator',
                       action='store_true', dest='oscillator',
                       default=False, help=helps['oscillator'])
    group.add_argument('--well',
                       action='store_true', dest='well',
                       default=False, help=helps['well'])
    group.add_argument('--hydrogen',
                       action='store_true', dest='hydrogen',
                       default=False, help=helps['hydrogen'])
    group.add_argument('--boron',
                       action='store_true', dest='boron',
                       default=False, help=helps['boron'])
    parser.add_argument('-n', '--n-eigs', type=int, metavar='int',
                        action='store', dest='n_eigs',
                        default=None, help=helps['n_eigs'])
    parser.add_argument('-t', '--tau', type=float, metavar='float',
                        action='store', dest='tau',
                        default=None, help=helps['tau'])
    parser.add_argument('filename_in', nargs='?')
    options = parser.parse_args()

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

    filename_in = options.filename_in

    if not filename_in:
        if options.oscillator:
            filename_in = fix_path("examples/quantum/oscillator.py")

        elif options.well:
            filename_in = fix_path("examples/quantum/well.py")

        elif options.hydrogen:
            filename_in = fix_path("examples/quantum/hydrogen.py")

        elif options.boron:
            filename_in = fix_path("examples/quantum/boron.py")

        else:
            parser.print_help()
            return

    define_args = {}

    if options.n_eigs is not None:
        define_args['n_eigs'] = options.n_eigs

    if options.tau is not None:
        define_args['tau'] = options.tau

    required, other = get_standard_keywords()
    conf = ProblemConf.from_file_and_options(filename_in, options,
                                             required, other,
                                             define_args=define_args)

    app = SchroedingerApp(conf, options, 'schroedinger:')
    opts = conf.options
    if hasattr(opts, 'parametric_hook'): # Parametric study.
        parametric_hook = conf.get_function(opts.parametric_hook)
        app.parametrize(parametric_hook)
    app()
Esempio n. 4
0
def main():
    # if multi_mpi.cpu_count() < 2:
    #     raise ValueError('MPI mode - the number of nodes is less then 2!')

    if multi_mpi.mpi_rank == multi_mpi.mpi_master:
        # MPI master node - solve problem at macro scale
        parser = ArgumentParser(description=__doc__,
                                formatter_class=RawDescriptionHelpFormatter)
        parser.add_argument('--debug',
                            action='store_true',
                            dest='debug',
                            default=False,
                            help=helps['debug'])
        parser.add_argument('--debug_mpi',
                            action='store_true',
                            dest='debug_mpi',
                            default=False,
                            help=helps['debug_mpi'])
        parser.add_argument('-c',
                            '--conf',
                            metavar='"key : value, ..."',
                            action='store',
                            dest='conf',
                            type=str,
                            default=None,
                            help=helps['conf'])
        parser.add_argument('-O',
                            '--options',
                            metavar='"key : value, ..."',
                            action='store',
                            dest='app_options',
                            type=str,
                            default=None,
                            help=helps['options'])
        parser.add_argument('-d',
                            '--define',
                            metavar='"key : value, ..."',
                            action='store',
                            dest='define_args',
                            type=str,
                            default=None,
                            help=helps['define'])
        parser.add_argument('-o',
                            metavar='filename',
                            action='store',
                            dest='output_filename_trunk',
                            default=None,
                            help=helps['filename'])
        parser.add_argument('--format',
                            metavar='format',
                            action='store',
                            dest='output_format',
                            default=None,
                            help=helps['output_format'])
        parser.add_argument('--log',
                            metavar='file',
                            action='store',
                            dest='log',
                            default=None,
                            help=helps['log'])
        parser.add_argument('-q',
                            '--quiet',
                            action='store_true',
                            dest='quiet',
                            default=False,
                            help=helps['quiet'])
        group = parser.add_mutually_exclusive_group(required=True)
        group.add_argument('filename_in', nargs='?')
        options = parser.parse_args()

        for k in [
                'save_ebc', 'save_ebc_nodes', 'save_regions',
                'save_regions_as_groups', 'save_field_meshes', 'solve_not'
        ]:
            setattr(options, k, False)

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

        if options.debug_mpi:
            multi_mpi.set_logging_level('debug')

        filename_in = options.filename_in
        output.set_output(filename=options.log,
                          quiet=options.quiet,
                          combined=options.log is not None)

        required, other = get_standard_keywords()
        conf = ProblemConf.from_file_and_options(
            filename_in,
            options,
            required,
            other,
            define_args=options.define_args)

        opts = conf.options
        nslaves = multi_mpi.cpu_count() - 1
        opts.n_mpi_homog_slaves = nslaves
        output_prefix = opts.get('output_prefix', 'sfepy:')

        app = PDESolverApp(conf, options, output_prefix)
        if hasattr(opts, 'parametric_hook'):  # Parametric study.
            parametric_hook = conf.get_function(opts.parametric_hook)
            app.parametrize(parametric_hook)
        app()

        multi_mpi.master_send_task('finalize', None)
    else:
        # MPI slave mode - calculate homogenized coefficients
        homogen_app = None
        done = False
        rank = multi_mpi.mpi_rank
        while not done:
            task, data = multi_mpi.slave_get_task('main slave loop')

            if task == 'init':  # data: micro_file, n_micro
                output.set_output(filename='homog_app_mpi_%d.log' % rank,
                                  quiet=True)
                micro_file, n_micro = data[:2]
                required, other = get_standard_keywords()
                required.remove('equations')
                conf = ProblemConf.from_file(micro_file,
                                             required,
                                             other,
                                             verbose=False)
                options = Struct(output_filename_trunk=None)
                homogen_app = HomogenizationApp(conf,
                                                options,
                                                'micro:',
                                                n_micro=n_micro)
            elif task == 'calculate':  # data: rel_def_grad, ts, iteration
                macro_data, ts, iteration = data[:3]
                homogen_app.setup_macro_data(macro_data)
                homogen_app(ret_all=True, itime=ts.step, iiter=iteration)
            elif task == 'finalize':
                done = True
Esempio n. 5
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('-c',
                        '--conf',
                        metavar='"key : value, ..."',
                        action='store',
                        dest='conf',
                        type=str,
                        default=None,
                        help=helps['conf'])
    parser.add_argument('-O',
                        '--options',
                        metavar='"key : value, ..."',
                        action='store',
                        dest='app_options',
                        type=str,
                        default=None,
                        help=helps['options'])
    parser.add_argument('-d',
                        '--define',
                        metavar='"key : value, ..."',
                        action='store',
                        dest='define_args',
                        type=str,
                        default=None,
                        help=helps['define'])
    parser.add_argument('-o',
                        metavar='filename',
                        action='store',
                        dest='output_filename_trunk',
                        default=None,
                        help=helps['filename'])
    parser.add_argument('--format',
                        metavar='format',
                        action='store',
                        dest='output_format',
                        default=None,
                        help=helps['output_format'])
    parser.add_argument('--save-restart',
                        metavar='mode',
                        type=int,
                        action='store',
                        dest='save_restart',
                        default=None,
                        help=helps['save_restart'])
    parser.add_argument('--load-restart',
                        metavar='filename',
                        action='store',
                        dest='load_restart',
                        default=None,
                        help=helps['load_restart'])
    parser.add_argument('--log',
                        metavar='file',
                        action='store',
                        dest='log',
                        default=None,
                        help=helps['log'])
    parser.add_argument('-q',
                        '--quiet',
                        action='store_true',
                        dest='quiet',
                        default=False,
                        help=helps['quiet'])
    parser.add_argument('--save-ebc',
                        action='store_true',
                        dest='save_ebc',
                        default=False,
                        help=helps['save_ebc'])
    parser.add_argument('--save-ebc-nodes',
                        action='store_true',
                        dest='save_ebc_nodes',
                        default=False,
                        help=helps['save_ebc_nodes'])
    parser.add_argument('--save-regions',
                        action='store_true',
                        dest='save_regions',
                        default=False,
                        help=helps['save_regions'])
    parser.add_argument('--save-regions-as-groups',
                        action='store_true',
                        dest='save_regions_as_groups',
                        default=False,
                        help=helps['save_regions_as_groups'])
    parser.add_argument('--save-field-meshes',
                        action='store_true',
                        dest='save_field_meshes',
                        default=False,
                        help=helps['save_field_meshes'])
    parser.add_argument('--solve-not',
                        action='store_true',
                        dest='solve_not',
                        default=False,
                        help=helps['solve_not'])
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('--list',
                       metavar='what',
                       action='store',
                       dest='_list',
                       default=None,
                       help=helps['list'])
    group.add_argument('filename_in', nargs='?')
    options, petsc_opts = parser.parse_known_args()

    if options._list is not None:
        if options._list == 'terms':
            print_terms()

        elif options._list == 'solvers':
            print_solvers()

        return

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

    filename_in = options.filename_in
    output.set_output(filename=options.log,
                      quiet=options.quiet,
                      combined=options.log is not None)

    required, other = get_standard_keywords()
    if options.solve_not:
        required.remove('equations')
        required.remove('solver_[0-9]+|solvers')
        other.extend(['equations'])

    conf = ProblemConf.from_file_and_options(filename_in,
                                             options,
                                             required,
                                             other,
                                             define_args=options.define_args)

    opts = conf.options
    output_prefix = opts.get('output_prefix', 'sfepy:')

    opts.save_restart = options.save_restart
    opts.load_restart = options.load_restart

    if conf.options.get('evps') is None:
        app = PDESolverApp(conf, options, output_prefix)

    else:
        app = EVPSolverApp(conf, options, output_prefix)

    if hasattr(opts, 'parametric_hook'):  # Parametric study.
        parametric_hook = conf.get_function(opts.parametric_hook)
        app.parametrize(parametric_hook)
    app()
Esempio n. 6
0
def main():
    parser = OptionParser(usage=usage, version='%prog ' + sfepy.__version__)
    parser.add_option('-c',
                      '--conf',
                      metavar='"key : value, ..."',
                      action='store',
                      dest='conf',
                      type='string',
                      default=None,
                      help=help['conf'])
    parser.add_option('-O',
                      '--options',
                      metavar='"key : value, ..."',
                      action='store',
                      dest='app_options',
                      type='string',
                      default=None,
                      help=help['options'])
    parser.add_option('-o',
                      '',
                      metavar='filename',
                      action='store',
                      dest='output_filename_trunk',
                      default=None,
                      help=help['filename'])
    parser.add_option('--oscillator',
                      action='store_true',
                      dest='oscillator',
                      default=False,
                      help=help['oscillator'])
    parser.add_option('--well',
                      action='store_true',
                      dest='well',
                      default=False,
                      help=help['well'])
    parser.add_option('--hydrogen',
                      action='store_true',
                      dest='hydrogen',
                      default=False,
                      help=help['hydrogen'])
    parser.add_option('--boron',
                      action='store_true',
                      dest='boron',
                      default=False,
                      help=help['boron'])
    parser.add_option('-n',
                      '--n-eigs',
                      type='int',
                      metavar='int',
                      action='store',
                      dest='n_eigs',
                      default=None,
                      help=help['n_eigs'])
    parser.add_option('-t',
                      '--tau',
                      type='float',
                      metavar='float',
                      action='store',
                      dest='tau',
                      default=None,
                      help=help['tau'])

    options, args = parser.parse_args()

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

    elif len(args) == 0:
        if options.oscillator:
            filename_in = fix_path("examples/quantum/oscillator.py")

        elif options.well:
            filename_in = fix_path("examples/quantum/well.py")

        elif options.hydrogen:
            filename_in = fix_path("examples/quantum/hydrogen.py")

        elif options.boron:
            filename_in = fix_path("examples/quantum/boron.py")

        else:
            parser.print_help()
            return

    else:
        parser.print_help()
        return

    define_args = {}

    if options.n_eigs is not None:
        define_args['n_eigs'] = options.n_eigs

    if options.tau is not None:
        define_args['tau'] = options.tau

    required, other = get_standard_keywords()
    conf = ProblemConf.from_file_and_options(filename_in,
                                             options,
                                             required,
                                             other,
                                             define_args=define_args)

    app = SchroedingerApp(conf, options, 'schroedinger:')
    opts = conf.options
    if hasattr(opts, 'parametric_hook'):  # Parametric study.
        parametric_hook = conf.get_function(opts.parametric_hook)
        app.parametrize(parametric_hook)
    app()
Esempio n. 7
0
def main():
    parser = OptionParser(usage = usage, version = "%prog " + sfepy.__version__)
    parser.add_option('-c', '--conf', metavar='"key : value, ..."',
                      action='store', dest='conf', type='string',
                      default=None, help= help['conf'])
    parser.add_option('-O', '--options', metavar='"key : value, ..."',
                      action='store', dest='app_options', type='string',
                      default=None, help=help['options'])
    parser.add_option('-d', '--define', metavar='"key : value, ..."',
                      action='store', dest='define_args', type='string',
                      default=None, help=help['define'])
    parser.add_option( "-o", "", metavar = 'filename',
                       action = "store", dest = "output_filename_trunk",
                       default = None, help = help['filename'] )
    parser.add_option( "", "--format", metavar = 'format',
                       action = "store", dest = "output_format",
                       default = None, help = help['output_format'] )
    parser.add_option( "", "--log", metavar = 'file',
                       action = "store", dest = "log",
                       default = None, help = help['log'] )
    parser.add_option( "-q", "--quiet",
                       action = "store_true", dest = "quiet",
                       default = False, help = help['quiet'] )
    parser.add_option( "", "--save-ebc",
                       action = "store_true", dest = "save_ebc",
                       default = False, help = help['save_ebc'] )
    parser.add_option( "", "--save-regions",
                       action = "store_true", dest = "save_regions",
                       default = False, help = help['save_regions'] )
    parser.add_option( "", "--save-regions-as-groups",
                       action = "store_true", dest = "save_regions_as_groups",
                       default = False, help = help['save_regions_as_groups'] )
    parser.add_option( "", "--save-field-meshes",
                       action = "store_true", dest = "save_field_meshes",
                       default = False, help = help['save_field_meshes'] )
    parser.add_option( "", "--solve-not",
                       action = "store_true", dest = "solve_not",
                       default = False, help = help['solve_not'] )
    parser.add_option( "", "--list", metavar = 'what',
                       action = "store", dest = "_list",
                       default = None, help = help['list'] )

    options, args = parser.parse_args()

    if (len( args ) == 1):
        filename_in = args[0];
    else:
        if options._list == 'terms':
            print_terms()
        else:
            parser.print_help(),
        return

    output.set_output(filename=options.log,
                      quiet=options.quiet,
                      combined=options.log is not None)

    required, other = get_standard_keywords()
    if options.solve_not:
        required.remove( 'equations' )
        required.remove( 'solver_[0-9]+|solvers' )
        other.extend( ['equations'] )

    conf = ProblemConf.from_file_and_options(filename_in, options,
                                             required, other,
                                             define_args=options.define_args)

    opts = conf.options
    output_prefix = get_default_attr( opts, 'output_prefix', 'sfepy:' )

    app = SimpleApp( conf, options, output_prefix )
    if hasattr( opts, 'parametric_hook' ): # Parametric study.
        parametric_hook = conf.get_function(opts.parametric_hook)
        app.parametrize( parametric_hook )
    app()
Esempio n. 8
0
def main():
    parser = OptionParser(usage=usage, version='%prog ' + sfepy.__version__)
    parser.add_option('-c', '--conf', metavar='"key : value, ..."',
                      action='store', dest='conf', type='string',
                      default=None, help= help['conf'])
    parser.add_option('-O', '--options', metavar='"key : value, ..."',
                      action='store', dest='app_options', type='string',
                      default=None, help=help['options'])
    parser.add_option('-o', '', metavar='filename',
                      action='store', dest='output_filename_trunk',
                      default=None, help=help['filename'])
    parser.add_option('--oscillator',
                      action='store_true', dest='oscillator',
                      default=False, help=help['oscillator'])
    parser.add_option('--well',
                      action='store_true', dest='well',
                      default=False, help=help['well'])
    parser.add_option('--hydrogen',
                      action='store_true', dest='hydrogen',
                      default=False, help=help['hydrogen'])
    parser.add_option('--boron',
                      action='store_true', dest='boron',
                      default=False, help=help['boron'])
    parser.add_option('-n', '--n-eigs', type='int', metavar='int',
                      action='store', dest='n_eigs',
                      default=None, help=help['n_eigs'])
    parser.add_option('-t', '--tau', type='float', metavar='float',
                      action='store', dest='tau',
                      default=None, help=help['tau'])

    options, args = parser.parse_args()

    if len(args) == 1:
        filename_in = args[0];

    elif len(args) == 0:
        if options.oscillator:
            filename_in = fix_path("examples/quantum/oscillator.py")

        elif options.well:
            filename_in = fix_path("examples/quantum/well.py")

        elif options.hydrogen:
            filename_in = fix_path("examples/quantum/hydrogen.py")

        elif options.boron:
            filename_in = fix_path("examples/quantum/boron.py")

        else:
            parser.print_help()
            return

    else:
        parser.print_help()
        return

    define_args = {}

    if options.n_eigs is not None:
        define_args['n_eigs'] = options.n_eigs

    if options.tau is not None:
        define_args['tau'] = options.tau

    required, other = get_standard_keywords()
    conf = ProblemConf.from_file_and_options(filename_in, options,
                                             required, other,
                                             define_args=define_args)

    app = SchroedingerApp(conf, options, 'schroedinger:')
    opts = conf.options
    if hasattr(opts, 'parametric_hook'): # Parametric study.
        parametric_hook = conf.get_function(opts.parametric_hook)
        app.parametrize(parametric_hook)
    app()
Esempio n. 9
0
def main():
    parser = OptionParser(usage=usage, version='%prog ' + sfepy.__version__)
    parser.add_option('-c', '--conf', metavar='"key : value, ..."',
                      action='store', dest='conf', type='string',
                      default=None, help= help['conf'])
    parser.add_option('-O', '--options', metavar='"key : value, ..."',
                      action='store', dest='app_options', type='string',
                      default=None, help=help['options'])
    parser.add_option('-d', '--define', metavar='"key : value, ..."',
                      action='store', dest='define_args', type='string',
                      default=None, help=help['define'])
    parser.add_option('-o', '', metavar='filename',
                      action='store', dest='output_filename_trunk',
                      default=None, help=help['filename'])
    parser.add_option('', '--format', metavar='format',
                      action='store', dest='output_format',
                      default=None, help=help['output_format'])
    parser.add_option('', '--log', metavar='file',
                      action='store', dest='log',
                      default=None, help=help['log'])
    parser.add_option('-q', '--quiet',
                      action='store_true', dest='quiet',
                      default=False, help=help['quiet'])
    parser.add_option('', '--save-ebc',
                      action='store_true', dest='save_ebc',
                      default=False, help=help['save_ebc'])
    parser.add_option('', '--save-ebc-nodes',
                      action='store_true', dest='save_ebc_nodes',
                      default=False, help=help['save_ebc_nodes'])
    parser.add_option('', '--save-regions',
                      action='store_true', dest='save_regions',
                      default=False, help=help['save_regions'])
    parser.add_option('', '--save-regions-as-groups',
                      action='store_true', dest='save_regions_as_groups',
                      default=False, help=help['save_regions_as_groups'])
    parser.add_option('', '--save-field-meshes',
                      action='store_true', dest='save_field_meshes',
                      default=False, help=help['save_field_meshes'])
    parser.add_option('', '--solve-not',
                      action='store_true', dest='solve_not',
                      default=False, help=help['solve_not'])
    parser.add_option('', '--list', metavar='what',
                      action='store', dest='_list',
                      default=None, help=help['list'])

    options, args = parser.parse_args()

    if (len(args) == 1):
        filename_in = args[0];
    else:
        if options._list == 'terms':
            print_terms()
        else:
            parser.print_help(),
        return

    output.set_output(filename=options.log,
                      quiet=options.quiet,
                      combined=options.log is not None)

    required, other = get_standard_keywords()
    if options.solve_not:
        required.remove('equations')
        required.remove('solver_[0-9]+|solvers')
        other.extend(['equations'])

    conf = ProblemConf.from_file_and_options(filename_in, options,
                                             required, other,
                                             define_args=options.define_args)

    opts = conf.options
    output_prefix = get_default_attr(opts, 'output_prefix', 'sfepy:')

    app = PDESolverApp(conf, options, output_prefix)
    if hasattr(opts, 'parametric_hook'): # Parametric study.
        parametric_hook = conf.get_function(opts.parametric_hook)
        app.parametrize(parametric_hook)
    app()
Esempio n. 10
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('-c', '--conf', metavar='"key : value, ..."',
                        action='store', dest='conf', type=str,
                        default=None, help= helps['conf'])
    parser.add_argument('-O', '--options', metavar='"key : value, ..."',
                        action='store', dest='app_options', type=str,
                        default=None, help=helps['options'])
    parser.add_argument('-d', '--define', metavar='"key : value, ..."',
                        action='store', dest='define_args', type=str,
                        default=None, help=helps['define'])
    parser.add_argument('-o', metavar='filename',
                        action='store', dest='output_filename_trunk',
                        default=None, help=helps['filename'])
    parser.add_argument('--format', metavar='format',
                        action='store', dest='output_format',
                        default=None, help=helps['output_format'])
    parser.add_argument('--save-restart', metavar='mode', type=int,
                        action='store', dest='save_restart',
                        default=None, help=helps['save_restart'])
    parser.add_argument('--load-restart', metavar='filename',
                        action='store', dest='load_restart',
                        default=None, help=helps['load_restart'])
    parser.add_argument('--log', metavar='file',
                        action='store', dest='log',
                        default=None, help=helps['log'])
    parser.add_argument('-q', '--quiet',
                        action='store_true', dest='quiet',
                        default=False, help=helps['quiet'])
    parser.add_argument('--save-ebc',
                        action='store_true', dest='save_ebc',
                        default=False, help=helps['save_ebc'])
    parser.add_argument('--save-ebc-nodes',
                        action='store_true', dest='save_ebc_nodes',
                        default=False, help=helps['save_ebc_nodes'])
    parser.add_argument('--save-regions',
                        action='store_true', dest='save_regions',
                        default=False, help=helps['save_regions'])
    parser.add_argument('--save-regions-as-groups',
                        action='store_true', dest='save_regions_as_groups',
                        default=False, help=helps['save_regions_as_groups'])
    parser.add_argument('--save-field-meshes',
                        action='store_true', dest='save_field_meshes',
                        default=False, help=helps['save_field_meshes'])
    parser.add_argument('--solve-not',
                        action='store_true', dest='solve_not',
                        default=False, help=helps['solve_not'])
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('--list', metavar='what',
                        action='store', dest='_list',
                        default=None, help=helps['list'])
    group.add_argument('filename_in', nargs='?')
    options = parser.parse_args()

    if options._list is not None:
        if options._list == 'terms':
            print_terms()

        elif options._list == 'solvers':
            print_solvers()

        return

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

    filename_in = options.filename_in
    output.set_output(filename=options.log,
                      quiet=options.quiet,
                      combined=options.log is not None)

    required, other = get_standard_keywords()
    if options.solve_not:
        required.remove('equations')
        required.remove('solver_[0-9]+|solvers')
        other.extend(['equations'])

    conf = ProblemConf.from_file_and_options(filename_in, options,
                                             required, other,
                                             define_args=options.define_args)

    opts = conf.options
    output_prefix = opts.get('output_prefix', 'sfepy:')

    opts.save_restart = options.save_restart
    opts.load_restart = options.load_restart

    app = PDESolverApp(conf, options, output_prefix)
    if hasattr(opts, 'parametric_hook'): # Parametric study.
        parametric_hook = conf.get_function(opts.parametric_hook)
        app.parametrize(parametric_hook)
    app()
Esempio n. 11
0
                               tetgenpath=tetgen_path)
                m = Mesh.from_file("tmp/t.1.node")
                m.write(mesh_filename, io="auto")
            output("...mesh written to %s" % mesh_filename)
            return

        else:
            parser.print_help()
            return

    else:
        parser.print_help()
        return

    required, other = get_standard_keywords()
    conf = ProblemConf.from_file_and_options(filename_in, options, required,
                                             other)

    if options.mesh:
        from sfepy.fem.mesh_generators import gen_mesh_from_string

        conf.filename_mesh = gen_mesh_from_string(options.mesh,
                                                  options.mesh_dir)

    elif auto_mesh_name and not sfepy.in_source_tree:
        conf.filename_mesh = mesh_filename
        conf.options.absolute_mesh_path = True

    app = SchroedingerApp(conf, options, 'schroedinger:')
    opts = conf.options
    if hasattr(opts, 'parametric_hook'):  # Parametric study.
        parametric_hook = conf.get_function(opts.parametric_hook)
Esempio n. 12
0
def main():
    parser = OptionParser(usage=usage, version="%prog " + sfepy.__version__)
    parser.add_option(
        "-c",
        "--conf",
        metavar='"key : value, ..."',
        action="store",
        dest="conf",
        type="string",
        default=None,
        help=help["conf"],
    )
    parser.add_option(
        "-O",
        "--options",
        metavar='"key : value, ..."',
        action="store",
        dest="app_options",
        type="string",
        default=None,
        help=help["options"],
    )
    parser.add_option(
        "-d",
        "--define",
        metavar='"key : value, ..."',
        action="store",
        dest="define_args",
        type="string",
        default=None,
        help=help["define"],
    )
    parser.add_option(
        "-o", "", metavar="filename", action="store", dest="output_filename_trunk", default=None, help=help["filename"]
    )
    parser.add_option(
        "", "--format", metavar="format", action="store", dest="output_format", default=None, help=help["output_format"]
    )
    parser.add_option("", "--log", metavar="file", action="store", dest="log", default=None, help=help["log"])
    parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False, help=help["quiet"])
    parser.add_option("", "--save-ebc", action="store_true", dest="save_ebc", default=False, help=help["save_ebc"])
    parser.add_option(
        "", "--save-ebc-nodes", action="store_true", dest="save_ebc_nodes", default=False, help=help["save_ebc_nodes"]
    )
    parser.add_option(
        "", "--save-regions", action="store_true", dest="save_regions", default=False, help=help["save_regions"]
    )
    parser.add_option(
        "",
        "--save-regions-as-groups",
        action="store_true",
        dest="save_regions_as_groups",
        default=False,
        help=help["save_regions_as_groups"],
    )
    parser.add_option(
        "",
        "--save-field-meshes",
        action="store_true",
        dest="save_field_meshes",
        default=False,
        help=help["save_field_meshes"],
    )
    parser.add_option("", "--solve-not", action="store_true", dest="solve_not", default=False, help=help["solve_not"])
    parser.add_option("", "--list", metavar="what", action="store", dest="_list", default=None, help=help["list"])

    options, args = parser.parse_args()

    if len(args) == 1:
        filename_in = args[0]
    else:
        if options._list == "terms":
            print_terms()
        else:
            parser.print_help(),
        return

    output.set_output(filename=options.log, quiet=options.quiet, combined=options.log is not None)

    required, other = get_standard_keywords()
    if options.solve_not:
        required.remove("equations")
        required.remove("solver_[0-9]+|solvers")
        other.extend(["equations"])

    conf = ProblemConf.from_file_and_options(filename_in, options, required, other, define_args=options.define_args)

    opts = conf.options
    output_prefix = opts.get("output_prefix", "sfepy:")

    app = PDESolverApp(conf, options, output_prefix)
    if hasattr(opts, "parametric_hook"):  # Parametric study.
        parametric_hook = conf.get_function(opts.parametric_hook)
        app.parametrize(parametric_hook)
    app()