|
[Sponsors] |
storing coordinates in array of various blocks with different sizes (structured grid) |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 19, 2015, 06:32 |
storing coordinates in array of various blocks with different sizes (structured grid)
|
#1 |
Senior Member
Tom-Robin Teschner
Join Date: Dec 2011
Location: Cranfield, UK
Posts: 204
Rep Power: 16 |
hey there,
I am currently developing a structured mesh based solver with curve linear coordinates and hence my mesh is composed of various blocks. I am wondering how to best store the coordinates (in fortran). If the number of points per block in x and y (in 2d) would be the same for all blocks, it would be straight forward and I would have something like coordinateX(nblocks,nx,ny) but what happens if I have blocks of different sizes? I can't declare enough arrays before hand (like coordinateX1, coordinateX2, coordinate X3 ...) as that would limit the number of blocks per mesh, I also don't want to declare the array with the maximum number of points in x and y as I would waste a lot of computer resources. I'd like to stick with fortran for this problem but I know that in C/C++ it would have been a no brainer (but not an option at the moment). any ideas? |
|
August 19, 2015, 12:19 |
|
#2 | |
Senior Member
Troy Snyder
Join Date: Jul 2009
Location: Akron, OH
Posts: 219
Rep Power: 18 |
Quote:
size and de-allocate as needed. An example... Code:
integer,parameter:: prec=selected_real_kind(15,307) real(kind=prec),dimension(:,:,:),allocatable:: coordinateX ...some code... allocate( coordinateX(nx,ny,nz) ) ...some code making use of coordinateX... deallocate( coordinateX ) |
||
August 19, 2015, 14:29 |
|
#3 |
Senior Member
Tom-Robin Teschner
Join Date: Dec 2011
Location: Cranfield, UK
Posts: 204
Rep Power: 16 |
no, the problem is that nx, ny and nz are different for each block. you could declare one new array for each block but then you would need to know how many blocks you have in advance which somewhat limits you (as stated before).
but i found a solution that is working for me now which comes from unstructured grids (where i feel more comfortable) by having 3 arrays, i.e. coordinateX, coordinateY and coordinateZ where I store all the x,y and z coordinates of all the blocks. that means that these 3 arrays do not necessarily have the same length. then i have a helper array which states from where to where each block is placed inside the coordinate arrays. for example i could have coordinateX = [ 1 0 0 2 0 0 ] and helper(1,1) = 1, helper(1,2) = 3 and helper(2,1) = 4, helper(2,2) = 6. in this case i have two blocks, the first one goes from element 1 to 3 and the second block goes from 4-6. not the most elegant way i find but maybe someone comes up with a better solution. i just put it here in detail in case someone is coming across the same problem and can live with this fix. |
|
August 19, 2015, 14:40 |
|
#4 |
Senior Member
Troy Snyder
Join Date: Jul 2009
Location: Akron, OH
Posts: 219
Rep Power: 18 |
Ok, now I see the issue.
Your solution sounds very similar to the method employed in the Ferziger and Peric book. Therein all data is stored in 1D arrays with an appropriate indexing function that incorporates a block identifier, and the i,j,k indices of block of interest. In your case, the indexing function could simply evolve as the blocks are created rather than be set a priori. |
|
August 19, 2015, 14:48 |
|
#5 |
Senior Member
Tom-Robin Teschner
Join Date: Dec 2011
Location: Cranfield, UK
Posts: 204
Rep Power: 16 |
yeah, well, if ferziger and peric are using the same approach, I can't be that much off I guess. I got it from the book of Rainald Löhner (applied cfd techniques) but as I said in the context of unstructured grids. But I guess I have to put up with those more cumbersome datastructure
|
|
August 20, 2015, 02:53 |
|
#6 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,399
Rep Power: 46 |
How about using allocatable arrays of derived types in fortran?
Something like this... Code:
TYPE :: positions REAL(DP), DIMENSION(3) :: pos END TYPE positions TYPE :: points TYPE(positions), DIMENSION(:), ALLOCATABLE :: point END TYPE points TYPE(points), DIMENSION(:), ALLOCATABLE :: block |
|
August 20, 2015, 04:14 |
|
#7 |
Senior Member
Tom-Robin Teschner
Join Date: Dec 2011
Location: Cranfield, UK
Posts: 204
Rep Power: 16 |
I was not aware of derived types in fortran. Will do some reading up and see if I can use this structure, thanks
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mesh Conversion : structured to unstructured | shreyasr | ANSYS | 8 | April 8, 2019 07:03 |
[OpenFOAM] View grid coordinates in Paraview | ozzythewise | ParaView | 3 | June 6, 2017 04:12 |
convert a structured multiblock grid to an one unstructured: modification of cells | Mirage | ANSYS | 0 | July 18, 2012 09:14 |
Grid Independent Solution | Chuck Leakeas | Main CFD Forum | 2 | May 26, 2000 11:18 |
Grid generator for structured grids | Tore Myhrvold | Main CFD Forum | 5 | January 21, 1999 08:09 |