예제 #1
0
def main():
    import pdb
    import os, sys, math
    import numpy as n
    from bc import SortNodeIDs, extractPlane

    if sys.version < '2.6':
        sys.exit("ERROR: Requires Python >= v2.6")

    from optparse import OptionParser

    # lets read in some command-line arguments
    parser = OptionParser(
        usage=
        "Generate compression conditions for the top surface of the specified mesh.  \n\n%prog [OPTIONS]...",
        version="%s" % __version__)
    parser.add_option(
        "--loadfile",
        dest="loadfile",
        help="compression load defintion output file [default = %default]",
        default="topload.dyn")
    parser.add_option("--nodefile",
                      dest="nodefile",
                      help="node definition input file [default = %default]",
                      default="nodes.dyn")

    (opts, args) = parser.parse_args()

    # open the top load file to write
    LOADFILE = open(opts.loadfile, 'w')
    LOADFILE.write("*BOUNDARY_PRESCRIBED_MOTION_NODE\n")
    LOADFILE.write(
        "$ Generated using %s (version %s) with the following options:\n" %
        (sys.argv[0], __version__))
    LOADFILE.write("$ %s\n" % opts)

    # load in all of the node data, excluding '*' lines
    nodeIDcoords = n.loadtxt(opts.nodefile,
                             delimiter=',',
                             comments='*',
                             dtype=[('id', 'i4'), ('x', 'f4'), ('y', 'f4'),
                                    ('z', 'f4')])

    # there are 6 faces in these models; we need to (1) find the top face and (2) apply the appropriate loads
    [snic, axes] = SortNodeIDs(nodeIDcoords)

    # extract spatially-sorted node IDs on a the top z plane
    plane = (2, axes[2].max())
    planeNodeIDs = extractPlane(snic, axes, plane)

    # write out nodes on the top z plane with corresponding load values
    #(direction of motion, nodal displacement (accel, vel, etc), temporal load curve ID, scale factor for load curve)
    writeNodeLoads(LOADFILE, planeNodeIDs, '3,2,1,-1.0')
    LOADFILE.write("*END\n")

    # close all of our files open for read/write
    LOADFILE.close()
예제 #2
0
def main():
    import pdb 
    import os,sys,math
    import numpy as n
    from bc import SortNodeIDs, extractPlane

    if sys.version < '2.6':
        sys.exit("ERROR: Requires Python >= v2.6")

    from optparse import OptionParser

    # lets read in some command-line arguments
    parser = OptionParser(usage="Generate compression conditions for the top surface of the specified mesh.  \n\n%prog [OPTIONS]...",version="%s" % __version__)
    parser.add_option("--loadfile",dest="loadfile",help="compression load defintion output file [default = %default]",default="topload.dyn")
    parser.add_option("--nodefile",dest="nodefile",help="node definition input file [default = %default]",default="nodes.dyn")

    (opts,args) = parser.parse_args()

    # open the top load file to write
    LOADFILE = open(opts.loadfile,'w')
    LOADFILE.write("*BOUNDARY_PRESCRIBED_MOTION_NODE\n")
    LOADFILE.write("$ Generated using %s (version %s) with the following options:\n" % (sys.argv[0],__version__))
    LOADFILE.write("$ %s\n" % opts)
    
    # load in all of the node data, excluding '*' lines
    nodeIDcoords = n.loadtxt(opts.nodefile, delimiter=',', comments='*', dtype=[('id','i4'),('x','f4'),('y','f4'),('z','f4')])

    # there are 6 faces in these models; we need to (1) find the top face and (2) apply the appropriate loads
    [snic, axes] = SortNodeIDs(nodeIDcoords)
    
    # extract spatially-sorted node IDs on a the top z plane
    plane = (2,axes[2].max())
    planeNodeIDs = extractPlane(snic,axes,plane)

    # write out nodes on the top z plane with corresponding load values 
    #(direction of motion, nodal displacement (accel, vel, etc), temporal load curve ID, scale factor for load curve)
    writeNodeLoads(LOADFILE,planeNodeIDs,'3,2,1,-1.0')
    LOADFILE.write("*END\n")

    # close all of our files open for read/write
    LOADFILE.close()
예제 #3
0
def main():
    import sys
    import numpy as n
    from bc import SortNodeIDs, extractPlane
    import fem_mesh

    fem_mesh.check_version()

    opts = read_cli()
    loadtype = opts.loadtype
    direction = int(opts.direction)
    amplitude = float(opts.amplitude)
    lcid = int(opts.lcid)

    # open the top load file to write
    LOADFILE = open(opts.loadfile, 'w')
    if loadtype == 'disp' or loadtype == 'vel' or loadtype == 'accel':
        LOADFILE.write("*BOUNDARY_PRESCRIBED_MOTION_NODE\n")
    elif loadtype == 'force':
        LOADFILE.write("*LOAD_NODE_POINT\n")
    else:
        sys.exit('ERROR: Invalid loadtype specified (can only be disp, '
                 'force, vel or accel)')

    LOADFILE.write("$ Generated using %s with the following "
                   "options:\n" % sys.argv[0])
    LOADFILE.write("$ %s\n" % opts)

    # load in all of the node data, excluding '*' lines
    header_comment_skips = fem_mesh.count_header_comment_skips(opts.nodefile)
    nodeIDcoords = n.loadtxt(opts.nodefile,
                             delimiter=',',
                             skiprows=header_comment_skips,
                             comments='*',
                             dtype=[('id', 'i4'), ('x', 'f4'),
                                    ('y', 'f4'), ('z', 'f4')])

    # there are 6 faces in these models; we need to (1) find the top face and
    # (2) apply the appropriate loads
    [snic, axes] = SortNodeIDs(nodeIDcoords)

    # extract spatially-sorted node IDs on a the top z plane
    plane = (2, axes[2].max())
    planeNodeIDs = extractPlane(snic, axes, plane)

    # write out nodes on the top z plane with corresponding load values
    # (direction of motion, nodal displacement (accel, vel, etc), temporal load
    # curve ID, scale factor for load curve)
    # TODO: would like to clean this up with a dictionary to associate the
    # prescribed motions with their integer IDs with one statement instead of
    # three conditional statements below
    if loadtype == 'disp':
        writeNodeLoads(LOADFILE, planeNodeIDs, '%i,2,%i,%f' %
                       (direction, lcid, amplitude))
    elif loadtype == 'vel':
        writeNodeLoads(LOADFILE, planeNodeIDs, '%i,0,%i,%f' %
                       (direction, lcid, amplitude))
    elif loadtype == 'accel':
        writeNodeLoads(LOADFILE, planeNodeIDs, '%i,1,%i,%f' %
                       (direction, lcid, amplitude))
    elif loadtype == 'force':
        writeNodeLoads(LOADFILE, planeNodeIDs, '%i,%i,%f' %
                       (direction, lcid, amplitude))

    LOADFILE.write("*END\n")

    # close all of our files open for read/write
    LOADFILE.close()
예제 #4
0
def main():
    import os,sys,math
    import numpy as n
    from bc import SortNodeIDs, extractPlane

    if sys.version < '2.7':
        sys.exit("ERROR: Requires Python >= v2.7") # needed for argparse

    import argparse

    # lets read in some command-line arguments
    parser = argparse.ArgumentParser(description="Generate loading conditions for the top surface of the specified mesh.",formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument("--loadfile",help="compression load defintion output file",default="topload.dyn")
    parser.add_argument("--nodefile",help="node definition input file",default="nodes.dyn")
    parser.add_argument("--loadtype",help="apply nodal prescribed displacements (disp), point loads (force), velocity (vel) or acceleration (accel)",default="disp")
    parser.add_argument("--direction",help="direction of load [1 - x, 2 - y, 3 - z]",default=3)
    parser.add_argument("--amplitude",help="amplitude of load",default=1.0)
    parser.add_argument("--lcid",help="Load Curve ID (as function of time) to apply to these loads",default=1)

    opts = parser.parse_args()
    loadtype = opts.loadtype
    direction = int(opts.direction)
    amplitude = float(opts.amplitude)
    lcid = int(opts.lcid)

    # open the top load file to write
    LOADFILE = open(opts.loadfile,'w')
    if loadtype == 'disp' or loadtype == 'vel' or loadtype == 'accel':
        LOADFILE.write("*BOUNDARY_PRESCRIBED_MOTION_NODE\n")
    elif loadtype == 'force':
        LOADFILE.write("*LOAD_NODE_POINT\n")
    else:
        sys.exit('ERROR: Invalid loadtype specified (can only be disp, force, vel or accel)')

    LOADFILE.write("$ Generated using %s (version %s) with the following options:\n" % (sys.argv[0],__version__))
    LOADFILE.write("$ %s\n" % opts)
    
    # load in all of the node data, excluding '*' lines
    nodeIDcoords = n.loadtxt(opts.nodefile, delimiter=',', comments='*', dtype=[('id','i4'),('x','f4'),('y','f4'),('z','f4')])

    # there are 6 faces in these models; we need to (1) find the top face and (2) apply the appropriate loads
    [snic, axes] = SortNodeIDs(nodeIDcoords)
    
    # extract spatially-sorted node IDs on a the top z plane
    plane = (2,axes[2].max())
    planeNodeIDs = extractPlane(snic,axes,plane)

    # write out nodes on the top z plane with corresponding load values 
    # (direction of motion, nodal displacement (accel, vel, etc), temporal load
    # curve ID, scale factor for load curve)
    # TODO: would like to clean this up with a dictionary to associate the prescribed motions with their integer IDs with one statement instead of three conditional statements below
    if loadtype == 'disp':
        writeNodeLoads(LOADFILE,planeNodeIDs,'%i,2,%i,%f' % (direction,lcid,amplitude))
    elif loadtype == 'vel':
        writeNodeLoads(LOADFILE,planeNodeIDs,'%i,0,%i,%f' % (direction,lcid,amplitude))
    elif loadtype == 'accel':
        writeNodeLoads(LOADFILE,planeNodeIDs,'%i,1,%i,%f' % (direction,lcid,amplitude))
    elif loadtype == 'force':
        writeNodeLoads(LOADFILE,planeNodeIDs,'%i,%i,%f' % (direction,lcid,amplitude))
    
    LOADFILE.write("*END\n")

    # close all of our files open for read/write
    LOADFILE.close()