KADATH SPECTRAL SOLVER

Tutorial 2 : The Space

The various classes Space of Kadath are used to describe the various numerical domains. Each domain knows its geometry and the number of spectral points used. The space also encodes the relation between the various domains.

Setting the space

The constructor's arguments depend on the type of space considered but there are things that are commonly used :

  • the number of domains
  • The type of basis (Chebyshev or Legendre)
  • The number of points in each domain

Warning :

due to the use of FFTW, the number of points cannot be arbitrary and depends on the spectral basis. Rule of thumb : for phi variables use integers of the form 2^m 3^n 5^p and 2^m 3^n 5^p +1 for other coordinates. For instance in the radial direction, 11, 13, 17, 21, 25, 33 are admissible numbers.

// Example of a spherical space 
// Consists of several 3D spherical domains

    // 3D :
    int dim = 3 ;

    // Number of points
    Dim_array res (dim) ;
    res.set(0) = 13 ; // Points in r 
    res.set(1) = 5 ; // Points in theta
    res.set(2) = 4 ; // Points in phi

    // Absolute coordinates of the center
    Point center (dim) ;
    for (int i=1 ; i<=dim ; i++)
         center.set(i) = 0 ;

    // Number of domains and boundaries :
    int ndom = 4 ;
    Array<double> bounds (ndom-1) ;
    bounds.set(0) = 1 ; bounds.set(1) = 2 ; bounds.set(2) = 4 ;

    // Chebyshev or Legendre :
    int type_coloc = CHEB_TYPE ;

    // Spherical space constructor
    Space_spheric space(type_coloc, center, res, bounds) ;
    cout << space << endl ;

Some accessors

Individual domains can be accessed via the get_domain function that returns a pointer.

The domains have various functions that can be used to get things pertinent to each domain. One can mention getting the number of collocation points, the number of coefficients, the radius at each collocation point etc...

// Prints the number of points in the domain 0
cout << space.get_domain(0)->get_nbr_points() << endl ;

// Prints the number of coefficients in the domain 1 
cout << space.get_domain(1)->get_nbr_coefs() << endl ;

// Returns the radius in the domain 0
cout << space.get_domain(0)->get_radius() << endl ;

// Returns the X coordinate in the domain 1
cout << space.get_domain(1)->get_cart(1) << endl ;