CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   A Question on Multi-Rectangular Grids (https://www.cfd-online.com/Forums/main/2229-question-multi-rectangular-grids.html)

Bharanidharan Rajamani June 11, 2000 04:02

A Question on Multi-Rectangular Grids
 
Hi,

I am confronted with a problem of writing a code for generating a multi-rectangular domain. The domain will have different number of maxima and minima in both x and y direction (which should be given at users discretion). I want to use the optimal resource of memeory by an effective programming technique, like say Dynamic Memeory Allocation (Not sure if this will work) so that the relevant grid points alone are stored and not all points in the rectangle encompassing the whole grid which in other words means that my grid file should not store data more than it needs to. Also if somebody can help me solve this problem, generally without the above-specified programming issues, it will be helpful. Thanks.

Bharanidharan Rajamani.

John C. Chien June 11, 2000 11:48

Re: A Question on Multi-Rectangular Grids
 
(1). In C++, you can use NEW to reserve memory space and get the pointer which pointed to the type of the variable reserved. You can assign this pointer to the declared pointer variable. (2). You can use the pointer to manipulate the values stored. When you are done with the variable, release the memory space by using the DELETE pointer. (3). For more information, read the C++ text books. (4). You can use NEW to reserve the memory space form the "free store" for interger, floating point variables, array, structure, class,..

Cfd June 12, 2000 18:58

Re: A Question on Multi-Rectangular Grids
 
Hello Ram,

Is the number of active cells going to be much smaller than the peak value of Imax*Jmax? Because otherwise, optimisation is pointless.

If the answer is yes, one possibility is to save the logical indices (if needed) in a separate array, and just have the number of cells needed. For example, suppose you want to limit the grid to 100,000 cells totally, with peak values Imax=1000, Jmax=1000. Then define all your arrays to 100,000 eg U(100000), V(100000) etc, and an index array INDEX(100000) which can store the I and J [INDEX(ICELL)=(J-1)*1000+I]. It may also help to save the neighbours of each cell to avoid searches on I and J (eg. NORTH(ICELL) saves the J+1 neighbour of cell ICELL). This will cost you 4 additional arrays.

The bright side of doing all this right: You are now ready to go to unstructured grids! Just ignore all the business about I and J, and simply use the neighbour lists.


All times are GMT -4. The time now is 06:52.