Channelflow 2.0

Fourier Coefficients in y

Hi all,

I am new to both c++ and channelflow so I would advice some patience. I am trying to extract the fourier coefficients in both x and z direction ( \hat u(kx,y,kz) ) which are function of y.

On channelflow 1.0, I think it would be u.makeState(spectral,physical), how can I achieve this in channelflow 2.0?

On Matlab, this would be equivalent to taking a 2D FFT of each slice of velocity in the y direction, but I would like to utilise channelflow 2.0 more and learn more about c++.


Chi Hin

Hi Chi Hin,

This looks fine and should still work in Channelflow 2.0.


Thank you Jake,

I make the following edits in simulateflow.cpp but I still get physical velocities at gridpoints in my output files from to Here’s a snippet from simulateflow.cpp which I added fields[0].makeSpectral_xz() before saving.

    if (saveint != 0 && i % saveint == 0) {
        fields[0].save(outdir + label + t2s(t, inttime));
        if (savep)
            fields[1].save(outdir + "p" + t2s(t, inttime));

Since I am writing my files in .nc format (NetCDF), I have also seen that the writeNetCDF function in flowfield.cpp only allows for physical numbers, it that the reason why I can’t output fourier coefficents?

Chi Hin

That’s right - it transforms back to physical space before it writes. You can try writing in ascii (.asc) or .ff (the old channelflow format) which I think should work in spectral or physical. There is a saveSpectrum function too, which I’ve not used but you might want to look at.