Exemplo n.º 1
0
def setupDNS(sum, where, config, get_FFT, **kwargs):
    
    params = config.params
    L = params.L
    FFT = get_FFT(params)
    float, complex, mpitype = datatypes(params.precision)
    X = FFT.get_local_mesh()
    K = FFT.get_scaled_local_wavenumbermesh()    
    K2 = sum(K*K, 0, dtype=float)
    K_over_K2 = K.astype(float) / where(K2==0, 1, K2).astype(float)    
    
    U     = empty((3,) + FFT.real_shape(), dtype=float)  
    U_hat = empty((3,) + FFT.complex_shape(), dtype=complex)
    P     = empty(FFT.real_shape(), dtype=float)
    P_hat = empty(FFT.complex_shape(), dtype=complex)

    # RHS array
    dU     = empty((3,) + FFT.complex_shape(), dtype=complex)

    # 
    curl   = empty((3,) + FFT.real_shape(), dtype=float)   
    Source = None
    
    work = work_arrays()
    
    del kwargs
    return locals() # Lazy (need only return what is needed)
Exemplo n.º 2
0
def setupMHD(sum, where, config, get_FFT, **kwargs):
    
    params = config.params
    FFT = get_FFT(params)
    float, complex, mpitype = datatypes(params.precision)
    X = FFT.get_local_mesh()
    K = FFT.get_scaled_local_wavenumbermesh()
    K2 = sum(K*K, 0, dtype=float)
    K_over_K2 = K.astype(float) / where(K2==0, 1, K2).astype(float)

    UB     = empty((6,) + FFT.real_shape(), dtype=float)  
    UB_hat = empty((6,) + FFT.complex_shape(), dtype=complex)
    P      = empty(FFT.real_shape(), dtype=float)
    P_hat  = empty(FFT.complex_shape(), dtype=complex)
    
    # Create views into large data structures
    U     = UB[:3] 
    U_hat = UB_hat[:3]
    B     = UB[3:]
    B_hat = UB_hat[3:]

    # RHS array
    dU = empty((6,) + FFT.complex_shape(), dtype=complex)

    # 
    curl   = empty((3,) + FFT.real_shape(), dtype=float)   
    Source = None

    work = work_arrays()
    
    del kwargs
    return locals() # Lazy (need only return what is needed)
Exemplo n.º 3
0
def setupBoussinesq(config, get_FFT, **kwargs):

    params = config.params
    FFT = get_FFT(params)
    float, complex, mpitype = datatypes(params.precision)    
    
    X = FFT.get_local_mesh()
    K = FFT.get_scaled_local_wavenumbermesh()

    Ur     = empty((3,) + FFT.real_shape(), dtype=float)
    Ur_hat = empty((3,) + FFT.complex_shape(), dtype=complex)
    P      = empty(FFT.real_shape(), dtype=float)
    P_hat  = empty(FFT.complex_shape(), dtype=complex)
    curl   = empty(FFT.real_shape(), dtype=float)
    dU     = empty((3,) + FFT.complex_shape(), dtype=complex)
     
    # Create views into large data structures
    rho     = Ur[2]
    rho_hat = Ur_hat[2]
    U       = Ur[:2] 
    U_hat   = Ur_hat[:2]

    K2 = sum(K*K, 0, dtype=float)
    K_over_K2 = K.astype(float) / where(K2==0, 1, K2).astype(float)    

    work = work_arrays()

    del kwargs
    return locals()
Exemplo n.º 4
0
def setupNS(config, get_FFT, **kwargs):
    
    params = config.params
    FFT = get_FFT(params)
    float, complex, mpitype = datatypes(params.precision)

    X = FFT.get_local_mesh()
    K = FFT.get_scaled_local_wavenumbermesh()

    # Solution array and Fourier coefficients
    U     = empty((2,) + FFT.real_shape(), dtype=float)
    U_hat = empty((2,) + FFT.complex_shape(), dtype=complex)
    P     = empty(FFT.real_shape(), dtype=float)
    P_hat = empty(FFT.complex_shape(), dtype=complex)
    curl  = empty(FFT.real_shape(), dtype=float)
    dU     = empty((2,) + FFT.complex_shape(), dtype=complex)
    
    K2 = sum(K*K, 0, dtype=float)
    K_over_K2 = K.astype(float) / where(K2==0, 1, K2).astype(float)    
    
    work = work_arrays()

    del kwargs
    return locals()
Exemplo n.º 5
0
    
  For Biharmonic basis with both homogeneous Dirichlet
  and Neumann:
  
    phi_k = T_k - 2(k+2)/(k+3)*T_{k+2} + (k+1)/(k+3)*T_{k+4}

Use either Chebyshev-Gauss (GC) or Gauss-Lobatto (GL)
points in real space.

The ChebyshevTransform may be used to compute derivatives
through fast Chebyshev transforms.

"""
float, complex = np.float64, np.complex128
pi, zeros, ones = np.pi, np.zeros, np.ones
work = work_arrays()

class ChebyshevTransform(object):
    
    def __init__(self, quad="GL", fast_transform=True): 
        self.quad = quad
        self.fast_transform = fast_transform
        self.points = None
        self.weights = None
                
    def points_and_weights(self, N):
        self.N = N
        if self.quad == "GL":
            points = (n_cheb.chebpts2(N)[::-1]).astype(float)
            #points = (n_cheb.chebpts2(N)).astype(float)
            weights = zeros(N)+pi/(N-1)
Exemplo n.º 6
0
#pylint: disable=bad-whitespace,arguments-differ
from collections import defaultdict
from numpy import array, zeros, zeros_like, sum, hstack, meshgrid, abs, \
    pi, uint8, rollaxis, arange
import numpy as np
from mpi4py import MPI
from mpiFFT4py import dct, work_arrays, Slab_R2C, fftfreq, rfftfreq, rfft2, \
    irfft2, rfft, irfft, fft, ifft
from ..optimization import optimizer

work = work_arrays()


class SlabShen_R2C(Slab_R2C):
    def __init__(self,
                 N,
                 L,
                 comm,
                 padsize=1.5,
                 threads=1,
                 communication='Alltoall',
                 dealias_cheb=False,
                 planner_effort=defaultdict(lambda: "FFTW_MEASURE",
                                            {"dct": "FFTW_EXHAUSTIVE"})):
        Slab_R2C.__init__(self,
                          N,
                          L,
                          comm,
                          "double",
                          padsize=padsize,
                          threads=threads,