CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

L shape domain discretization Matlab coding

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By sbaffini

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 2, 2021, 15:45
Default L shape domain discretization Matlab coding
  #1
New Member
 
Seyfi Girgin
Join Date: Aug 2015
Posts: 12
Rep Power: 10
seyfigirgin is on a distinguished road
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,
Attached Images
File Type: jpg Lshape.jpg (12.3 KB, 14 views)
seyfigirgin is offline   Reply With Quote

Old   March 2, 2021, 17:03
Default
  #2
Senior Member
 
Join Date: Oct 2011
Posts: 239
Rep Power: 16
naffrancois is on a distinguished road
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
naffrancois is offline   Reply With Quote

Old   March 3, 2021, 05:44
Default
  #3
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,151
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
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.
naffrancois and aero_head like this.
sbaffini is offline   Reply With Quote

Old   March 4, 2021, 10:22
Default
  #4
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,151
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
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
sbaffini is offline   Reply With Quote

Reply

Tags
conduction, heat, l shape, matlab, numeric


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CFX - specified domain intialization qntldoql CFX 4 September 28, 2020 09:28
CFD coding in Matlab sirak masresha Main CFD Forum 7 March 14, 2019 02:43
CFD coding with MATLAB or Fortran majidmanz Main CFD Forum 1 July 13, 2017 13:28
Pressure distribution on a wall darazsbence CFX 17 October 6, 2015 10:38
Setting rotating frame of referece. RPFigueiredo CFX 3 October 28, 2014 04:59


All times are GMT -4. The time now is 12:51.