def main():
    parser = OptionParser(usage=usage, version="%prog 42")
    parser.add_option("-s", "--scale", type=int, metavar='scale',
                      action="store", dest="scale",
                      default=2, help=help['scale'])
    parser.add_option("-r", "--repeat", type='str', metavar='nx,ny[,nz]',
                      action="callback", dest="repeat",
                      callback=parse_repeat, default=None, help=help['repeat'])
    parser.add_option("-e", "--eps", type=float, metavar='eps',
                      action="store", dest="eps",
                      default=1e-8, help=help['eps'])
    (options, args) = parser.parse_args()

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

    output = Output('tpm:')
    output('scale:', options.scale)
    output('repeat:', options.repeat)
    output('eps:', options.eps)

    mesh_in = Mesh.from_file(filename_in)
    mesh_out = gen_tiled_mesh(mesh_in, options.repeat, 1./options.scale,
                              options.eps)
    mesh_out.write(filename_out, io='auto')
    output('done.')
Beispiel #2
0
def main():
    parser = ArgumentParser(description=__doc__)
    parser.add_argument("--version", action="version", version="%(prog)s 42")
    parser.add_argument("-s", "--scale", type=int, metavar='scale',
                        action="store", dest="scale",
                        default=2, help=helps['scale'])
    parser.add_argument("-r", "--repeat", type=str, metavar='nx,ny[,nz]',
                        action=ParseRepeat, dest="repeat",
                        default=None, help=helps['repeat'])
    parser.add_argument("-e", "--eps", type=float, metavar='eps',
                        action="store", dest="eps",
                        default=1e-8, help=helps['eps'])
    parser.add_argument('filename_in')
    parser.add_argument('filename_out')
    options = parser.parse_args()

    filename_in = options.filename_in
    filename_out = options.filename_out

    output = Output('tpm:')
    output('scale:', options.scale)
    output('repeat:', options.repeat)
    output('eps:', options.eps)

    mesh_in = Mesh.from_file(filename_in)
    mesh_out = gen_tiled_mesh(mesh_in, options.repeat, 1./options.scale,
                              options.eps)
    mesh_out.write(filename_out, io='auto')
    output('done.')
    def test_gen_tiled_mesh(self):
        from sfepy.mesh.mesh_generators import gen_block_mesh, gen_tiled_mesh

        mesh0 = gen_block_mesh([1, 2, 3], [4, 3, 5], [2, 1, 0], verbose=False)
        mesh = gen_tiled_mesh(mesh0, [3, 1, 5])
        filename = op.join(self.options.out_dir, 'gen_tiled.mesh')
        mesh.write(filename)
        self.report('tiled mesh generated')

        csum = nm.sum(mesh.coors - nm.min(mesh.coors, axis=0), axis=0)
        return nm.linalg.norm(csum - nm.array([945, 630, 4725])) < tolerance
    def test_gen_tiled_mesh(self):
        from sfepy.mesh.mesh_generators import gen_block_mesh, gen_tiled_mesh

        mesh0 = gen_block_mesh([1, 2, 3], [4, 3, 5], [2, 1, 0], verbose=False)
        mesh = gen_tiled_mesh(mesh0, [3, 1, 5])
        filename = op.join(self.options.out_dir, 'gen_tiled.mesh')
        mesh.write(filename)
        self.report('tiled mesh generated')

        csum = nm.sum(mesh.coors - nm.min(mesh.coors, axis=0), axis=0)
        return nm.linalg.norm(csum - nm.array([945, 630, 4725])) < tolerance
Beispiel #5
0
def main():
    parser = ArgumentParser(description=__doc__)
    parser.add_argument("--version", action="version", version="%(prog)s 42")
    parser.add_argument("-s",
                        "--scale",
                        type=int,
                        metavar='scale',
                        action="store",
                        dest="scale",
                        default=2,
                        help=help['scale'])
    parser.add_argument("-r",
                        "--repeat",
                        type=str,
                        metavar='nx,ny[,nz]',
                        action=ParseRepeat,
                        dest="repeat",
                        default=None,
                        help=help['repeat'])
    parser.add_argument("-e",
                        "--eps",
                        type=float,
                        metavar='eps',
                        action="store",
                        dest="eps",
                        default=1e-8,
                        help=help['eps'])
    parser.add_argument('filename_in')
    parser.add_argument('filename_out')
    options = parser.parse_args()

    filename_in = options.filename_in
    filename_out = options.filename_out

    output = Output('tpm:')
    output('scale:', options.scale)
    output('repeat:', options.repeat)
    output('eps:', options.eps)

    mesh_in = Mesh.from_file(filename_in)
    mesh_out = gen_tiled_mesh(mesh_in, options.repeat, 1. / options.scale,
                              options.eps)
    mesh_out.write(filename_out, io='auto')
    output('done.')