CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Data structure handling in multiblock approach (https://www.cfd-online.com/Forums/main/12331-data-structure-handling-multiblock-approach.html)

CH September 29, 2006 05:42

Data structure handling in multiblock approach
 
Hello,

I would like to implement multiblock in my solver. The problem is how to organize the data structure.

Suppose I have a c-grid generated airfoil. Now I would like to extend the far field by placing a new block of rectangular grid behind it.

Originally, there's variables x(i,j),y(i,j),u(i,j) etc. So now how should the variables be organized?

If the orginal c-grid is block 1, should x(i,j) be x1(i,j) now, and the new block 2 be x2(i,j) etc.

Or block1 variables be x(1,i,j), block2 be x(2,i,j)

Or should block1 variables just remain the same while for block2, it'll continue from where block1 ends.

Btw, I'm using a FVM scheme with fortran. I have no experience so I hope those ppl who have done it before can recommend me the best approach.

Mani September 29, 2006 13:21

Re: Data structure handling in multiblock approach
 
First off, I hope you are not using anything older than Fortran 90.

> Or block1 variables be x(1,i,j), block2 be x(2,i,j)

This is one thing you should definitely not do! You are limiting your grid to the case that all blocks have the same dimensions (or you are waisting a lot of memory). It will also make it quite difficult to parallelize your code.

> should x(i,j) be x1(i,j) now, and the new block 2 be x2(i,j) etc.

This is much better, but you should try to write your code as general as possible, keeping in mind that you may want to treat more than just 2 blocks in the future. Make your code handle an arbitrary number of blocks. This can be done by defining a new data type "block", e.g.

type block

integer ni,nj

real(kind=8), dimension(:,:), pointer :: x,y,u

! ... add all other variables within a block

end type

And then you can define a given number of blocks by

type(block), dimension(:), allocatable :: blk

allocate(blk(n)) ! for n blocks

and then for each block you allocate space for x,y,u, and so on, e.g.

allocate(blk(i)%u(blk%ni,blk%nj))

and so on. I think you get the idea. If you're not familiar with derived types in Fortran get yourself a Fortran book and read carefully before you start programming. You can save yourself a lot of trouble debugging, maintaining, and extending your code later on, if you write it in a smart way (as much object oriented as possible in Fortran). In addition, your code will be quite easy to parallelize.

CH September 30, 2006 00:39

Re: Data structure handling in multiblock approach
 
thanks alot mani! that's definitely a more elegant way of implementation.

Vasanth October 5, 2006 18:51

Re: Data structure handling in multiblock approach
 
yes that is write.

If you want a multiblock grid then you need to have a data structure for the blocks. To connect each block with another you need buffer blocks.

if you want to take a second derivative then you need to have buffer blocks for the buffer blocks.

Vasanth



All times are GMT -4. The time now is 21:38.