Exemplo n.º 1
0
def fegrab(el,ns,set_id,wrt_file):
    
    ### FINITE ELEMENT RESPONSES ###
    start = time.time()    
    
    resp = np.zeros([ns,el**3])   
    for sn in xrange(ns):
        filename = "sq%s_%s%s_%s.dat" %(el,ns,set_id,sn+1)        
        resp[sn,...] = rr.res_red(filename,el,sn)
    
    np.save('r_%s%s' %(ns,set_id),resp)  
    
    end = time.time()
    timeE = np.round((end - start),3)    
    msg = 'Load FE results from .dat files for set %s%s: %s seconds' %(ns,set_id,timeE)
    rr.WP(msg,wrt_file)
    
    ## responses in frequency space
    start = time.time()
    
    resp_fft = np.fft.fftn(resp.reshape([ns,el,el,el]), axes = [1,2,3]) 
    del resp
    np.save('r_fft_%s%s' %(ns,set_id),resp_fft)  
    
    end = time.time()
    timeE = np.round((end - start),3)
    msg = 'Convert FE results to frequency space for set %s%s: %s seconds' %(ns,set_id,timeE)
    rr.WP(msg,wrt_file)
Exemplo n.º 2
0
def fegrab(el, ns, set_id, direc, wrt_file):

    # FINITE ELEMENT RESPONSES
    start = time.time()

    resp = np.zeros([ns, el**3])

    nwd = os.getcwd() + '/' + direc  # for unix
    # nwd = os.getcwd() + '\\' + direc
    os.chdir(nwd)

    for sn in xrange(ns):
        filename = "sq%s_%s%s_%s.dat" % (el, ns, set_id, sn + 1)
        resp[sn, ...] = rr.res_red(filename, el, sn)

    os.chdir('..')

    np.save('r_%s%s' % (ns, set_id), resp)

    end = time.time()
    timeE = np.round((end - start), 3)
    msg = 'Load FE results from .dat files for set %s%s: %s seconds' \
        % (ns, set_id, timeE)
    rr.WP(msg, wrt_file)

    # responses in frequency space
    start = time.time()

    resp_fft = np.fft.fftn(resp.reshape([ns, el, el, el]), axes=[1, 2, 3])
    del resp
    np.save('r_fft_%s%s' % (ns, set_id), resp_fft)

    print "selection of resp_fft"
    print resp_fft[0, 10, 10, 5:10]

    end = time.time()
    timeE = np.round((end - start), 3)
    msg = 'Convert FE results to frequency space for set %s%s: %s seconds' \
        % (ns, set_id, timeE)
    rr.WP(msg, wrt_file)