programming:flowfield_concatenation

*Matthew Salewski, 2009-07-22 17:47 *

~~DISCUSSION~~ Hello,

I would like to take a periodic solution, double its spanwise domain and insert two periods into the new, extended domain; or to put it another way, take a solution and copy it, then construct a new flowfield that is twice as large as the original solution in the spanwise direction, then concatenate the copy to the original solution and finally put the combined field in the new grid.

The code i am using is essentially this:

FlowField U_out(U_in.Nx(),U_in.Ny(),2*U_in.Nz(),U_in.Nd(),U_in.Lx(),2*U_in.Lz(), U_in.a(), U_in.b());

constructs a new field based on the geometric parameters of the input field, doubling spanwise parameters only.

for(int i=0; i<U_in.Nd(); ++i) for(int ny=0; ny<U_in.Ny(); ++ny) for(int nx=0; nx<U_in.Nx(); ++nx) for(int nn=0; nn<2; ++nn) for(int nz=0; nz<U_in.Nz(); ++nz) U_out(nx, ny, U_in.Nz()*nn+nz, i) = U_in(nx,ny,nz,i);

gives the new field the physical values from the input field.

The result is not what i expected; it is an expanded solution in the new domain (almost like a resize) but it is also messy. My methods for checking are running ./fieldprops, ./fieldplots and comapring between the input and new fields.

However, if (instead of doubling) 1 is used for 2, then U_out is just a copy of U_in.

I originally tried a friend function in flowfield.cpp that uses rdata_[] in much the same way as above, where the argument of rdata_[] is a modified version of the 'flatten()' function:

for(int nd = 0; nd<U_in.Nd_; nd++) for(int ny=0; ny<U_in.Ny_; ny++) for(int nx=0; nx<U_in.Nx_; nx++) for(int nn=0; nn<2; nn++) for(int nz=0; nz<U_in.Nz_; nz++) U_out.rdata_[nz + U_in.Nz_*(nn + 2*(nx + U_in.Nx_*(ny + U_in.Ny_*nd)))] = U_in.rdata_[nz + U_in.Nz_*(nx + U_in.Nx_*(ny + U_in.Ny_*nd))];

However, the former approach is much simpler (conceptually and in practice) and the results of these two approaches are pretty similar if not the same. I thouht the rdata_-approach could be used to circumvent the 'resize()' within the flowfield and =-overload constructors.

What is missing?

Cheers,

Matthew

programming/flowfield_concatenation.txt · Last modified: 2010/02/02 07:55 (external edit)