예제 #1
0
def read_ascii_output(fname, ftype):
    """
    Read Aero-F ascii outputs, either unsteady or sensitivity type files.

    Input
    -----
      fname : str
        filename of output file
      ftype : str
        type of file (unsteady or sensitivity)

    Output
    ------
      data - ndarray
        (if ftype != sensitivity) returns all information from an unsteady
        ascii output file, including timesteps, in a nstep x n matrix
      act  - ndarray
        (if ftype == sensitivity) returns active variable for each derivative
      val  - ndarray
        (if ftype == sensitivity) returns value of output(s)
      der  - ndarray
        (if ftype == sensitivity) returns derivatives of output(s)
    """

    # Check if file exists; if not return inf
    exists = glob(fname)
    if exists: nLines = count_lines(fname)
    if not exists or nLines == 1:
        return (None)

    data = np.loadtxt(fname, skiprows=1)
    if 'sensitivity' not in ftype.lower():
        return (data)
    else:
        if len(data.shape) > 1:
            # print(data)
            nout = int((data.shape[1] - 2) / 2.0)
            act = data[:, 1]
            val = data[-1, 2:2 + nout]
            der = data[:, 2 + nout:]
        else:
            nout = 1
            act = data[1]
            val = data[2:2 + nout]
            der = data[2 + nout:]

        return (act, val, der)
예제 #2
0
def xpost_stats(fname):

    nline = count_lines(fname)
    out = {'desc': None, 'nnode': None, 'ndof': None, 'nstep': None}

    f = open(fname, 'r')
    for k, line in enumerate(f):
        if k == 0:
            out['desc'] = line.rstrip('\n')
        if k == 1:
            out['nnode'] = int(line.rstrip('\n'))
        if k == 3:
            out['ndof'] = len([x for x in line.split(' ') if x])
            break
    f.close()

    out['nstep'] = (nline - 2) / (out['nnode'] + 1)
    return out
예제 #3
0
def nodeset_stats(fname):
    return ['nodes', count_lines(fname) - 2]