CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   L shape domain discretization Matlab coding (https://www.cfd-online.com/Forums/main/234318-l-shape-domain-discretization-matlab-coding.html)

seyfigirgin March 2, 2021 15:45

L shape domain discretization Matlab coding
 
1 Attachment(s)
Hi all,

We know how to discretize sqaure or rectagle domain into Matlab. First we set boundary conditions and then we start computing the internal nodes. However what if we want to discretize a non-rectngular domain such as L shape or a shape like in the attachment. How are we going to set the boundaries?

If anyone know please help me

Thanks,

naffrancois March 2, 2021 17:03

Hello,

You mainly have two methods to handle non squared geometries:
1) multiblock meshes
2) unstructured meshes

In 1) you basically split your geometry in several rectangular blocks whose edges match your geometry. Inside each 4-sided blocks, you have an internal quad-based mesh. You then have to deal with external boundaries (as you would for a rectangular geometry) and internal boundaries between blocks to exchange data

In 2) you mesh your domain with an unstructured meshing algorithm, usually made of triangles in 2D, I guess matlab has internal engine for this. This however breaks easy structured indexing (i-1,i,i+1) as you need to handle connectivity lists

sbaffini March 3, 2021 05:44

I remember that, as a student, I made the mistake of not taking the extra mile that separated my single block structured codes from the multiblock ones, despite being suggested to do so by the professor. So, I missed the chance to learn early a very basic mechanism used in several codes, even unstructured ones, for different purposes, like periodicity, parallel exchange, etc. Instead, I wrongly tought that learning multiblock would not be very useful, but still hard.

So, if this is for pedagogical purposes (e.g., part of a course on numerical PDE solution or CFD), I strongly suggest route 1 with multiblock meshes. It really requires very little to add it in MATLAB (maybe put the different blocks in different cell elements, add the relative loops on the cells and the proper treatment at the interfaces between blocks using ghost cells), and has a lot of value in perspective.

In contrast, the route 2 with the unstructured grid requires much more work if you start from a structured single block code and won't teach you anything beyond unstructured grids.

sbaffini March 4, 2021 10:22

Some suggestions to follow the first route, starting from a single block finite volume code (finite difference would work similarly):

1) Use positive codes for your boundary conditions and, if you haven't already, convert all of them to use ghost cells

2) Assign negative codes to the boundaries requiring copying data from other blocks/locations. This means both periodicity and interfaces between blocks. You can use the absolute value of the bc code to refer to the block where the values have to be taken. This should also work seamlessly for periodicity on the same block. Also note that, for quad/hexa blocks, you can arrange them so that if you need values for the (notional) xmax boundary of a block you can always pick them from the (notional) xmin boundary of the other block, so you don't need to specify anything beyond the origin block

3) Put all the exchanges in a dedicated routine that can work with any variable as input. As this isn't actually parallel you can write it just as you want, as simply as a loop on the destination boundaries and copying in the origin variables

4) Renumber the cells according to the block ordering and do your book keeping to make a cell on the border of a block to know the global number of its neighbor in the adjacent block

With this you should have all you need to make it work


All times are GMT -4. The time now is 04:18.