Chapter VI.3. Adaptors

Table of Contents

VI.3.1. Definition
VI.3.2. Usage
VI.3.3. Implementation for Fourier coefficients
VI.3.4. Parallel case

VI.3.1. Definition

An adaptor is responsible for converting data in algebraic expressions from one numerical discretization to another one. The abstract meaning of the data must not change in this process.

The conversion always consists in adapting the representation of the right-hand side to the one of the left hand side, hence the name.

VI.3.2. Usage

Using an adaptor is very simple: simply inclde coefficients/adapt.hpp, and pass the part of the right-hand side that you want to adapt to the adapt() function. The compiler is responsible for finding the right way to do the adaptation. At instanciation time, the proper specializations should be made available by including the files where they are defined. We now give a list of currently implemented adaptors.

VI.3.3. Implementation for Fourier coefficients

At present the only adaptor that is implemented is Fourier-based upsampling. It is defined in coefficients/functors/k_adaptors.hpp. Say that f1 is a node containing Fourier coefficients with a maximum wavenumber kmax, and g1 also contains Fourier coefficients but with a smaller cutoff wavenumber qmax.

If you attempt to make the assignment

f1 = g1; // Runtime error

you will get a runtime error (or even worse if you run with assertions turned off).

That's because the library always assumes that all nodes occuring in algebraic expressions have the same geometry. Nevertheless, since g1 represents a truncated Fourier series, it is natural to expect that assigning it to f1 will copy the values of the coefficients whose wavenumber k is such that |k| < qmax, and set the remaining coefficients to 0.

That's precisely what will happen if you execute the following instruction:

f1 = adapt(g1); // OK

To complicate things a little bit, say that f2 and g2 are other Fourier coefficients, f2 having the size of f1 and g2 the size of g1.

	f1 = adapt(g1+g2); // OK
	f1 = adapt(g1) + adapt(g2); // same but slower
	f1 = f2 + adapt(g1); // OK		
	f1 = f2; // OK
	f1 = adapt(f2); // same but slower;
	f1 = adapt(g1+f2); // Run-time error (g1 and f2 are incompatible)		
			

Finally, the library forbids adaptations that would result in loss of information, hence

	f2 = adapt(f1);
		

triggers a runtime error.

VI.3.4. Parallel case

It would be nice if Fourier adaptors would work between two sets of distributed Fourier coefficients having different sizes. Unfortunately, that would be require some gymnastic to redistribute the coefficients between processes, and has not been done yet.

At present, the adaptor works only to go from a local smaller array to a distributed larger array.