CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[blockMesh] Creating blockMeshDict from python

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree26Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 12, 2021, 17:25
Default
  #21
Senior Member
 
kandelabr's Avatar
 
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 211
Rep Power: 11
kandelabr is on a distinguished road
Quote:
Originally Posted by dlahaye View Post
Greetings,

Question: revolve with angle equal to 180 degrees or larger does not work, correct? This has to do with face orientation, correct?

Edit: I would like to revolve over 360 (full circle) degrees? How do I concatenate 4 revolves each over 90 degrees taking as base the result of the previous operation? How do i merge pairs at the end?

Edit again: found cylinder as building block. Will look into this first. Thx!

Thanks, Domenico.
Revolve is an operation that works on a single block. blockMesh probably won't let you build such a block.
What's planned next:
- a revolve on a collection of faces, creating multiple blocks
- a loft/elbow or something where you can also specify number of blocks in the lofted/revolved direction. this would allow you to create, for instance, a 360 degree torus from <n> blocks. you can do that now but you have to manually create those segments.
__________________
www.damogranlabs.com
kandelabr is offline   Reply With Quote

Old   August 13, 2021, 16:56
Default
  #22
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 844
Blog Entries: 1
Rep Power: 19
dlahaye is on a distinguished road
Attached what I managed to build thus far. Thanks again!
Attached Images
File Type: jpg geom.jpg (64.2 KB, 71 views)
kandelabr likes this.
dlahaye is offline   Reply With Quote

Old   August 15, 2021, 18:10
Default
  #23
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 844
Blog Entries: 1
Rep Power: 19
dlahaye is on a distinguished road
Greetings again.

Is there a function that allows to set in the file constant/polymesh/boundary the patch type entries for wall to "wall" instead of "patch" (as currently is the case)?

Doing in manually is a bit of burden.

Cheers, Domenico.
dlahaye is offline   Reply With Quote

Old   August 16, 2021, 15:04
Default
  #24
Senior Member
 
kandelabr's Avatar
 
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 211
Rep Power: 11
kandelabr is on a distinguished road
No as there is no real need for that - just use the createPatch utility. Here's a sample system/createPatchDict that does just that. Also note that you can leave the most numerous faces out of the classy_blocks script - blockMesh will name them defaultFaces and you can capture them all with createPatch. Saves you quite a lot of lines of code!

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.3.1                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// Do a synchronisation of coupled points after creation of any patches.
// Note: this does not work with points that are on multiple coupled patches
//       with transformations (i.e. cyclics).
pointSync false;

// Patches to create.
patches
(
    {
        name walls;
        patchInfo
        {
            type wall;
        }
        constructFrom patches;
        patches (defaultFaces);
    }
);

// ************************************************************************* //
dlahaye likes this.
__________________
www.damogranlabs.com
kandelabr is offline   Reply With Quote

Old   August 22, 2021, 15:26
Default
  #25
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 844
Blog Entries: 1
Rep Power: 19
dlahaye is on a distinguished road
Greetings again.

Question: is there an easy way to easily obtain doubly graded meshes (see e.g. Section 2.6 https://openfoamwiki.net/index.php/B..._blockMeshDict) using classy_blocks, other then editting the blockMeshDict file?

Thanks, Domern
dlahaye is offline   Reply With Quote

Old   August 23, 2021, 05:09
Default
  #26
Senior Member
 
kandelabr's Avatar
 
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 211
Rep Power: 11
kandelabr is on a distinguished road
As of this moment, unfortunately not. More sophisticated grading functions will be added later. If your geometry isn't too complicated and you don't want to edit grading, you can add more simple-graded blocks...
__________________
www.damogranlabs.com
kandelabr is offline   Reply With Quote

Old   August 23, 2021, 06:59
Default
  #27
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 844
Blog Entries: 1
Rep Power: 19
dlahaye is on a distinguished road
Thanks!

I will edit blockMesh to facilitate my simulations.

Best wishes, Domenico.
dlahaye is offline   Reply With Quote

Old   August 30, 2021, 16:09
Default
  #28
Member
 
Francisco T
Join Date: Nov 2011
Location: Melbourne, Australia
Posts: 64
Blog Entries: 1
Rep Power: 15
frantov is on a distinguished road
Thanks for the python code!
I agree! Blockmesh with topoSet and createPatch utilities are very powerful.
kandelabr likes this.
frantov is offline   Reply With Quote

Old   September 10, 2021, 08:51
Default
  #29
Member
 
Francisco T
Join Date: Nov 2011
Location: Melbourne, Australia
Posts: 64
Blog Entries: 1
Rep Power: 15
frantov is on a distinguished road
Greetings

I'm trying to build a geometry which has a cavity inside.
Similar to the attached image.

I guess I can figure out how to model the features outsid but I'm wondering about the cavity. The right image is a cut to see inside. How can we define a cavity?
Attached Images
File Type: jpg IMG_20210910_224429.jpg (44.0 KB, 38 views)
frantov is offline   Reply With Quote

Old   September 10, 2021, 10:46
Default
  #30
Senior Member
 
kandelabr's Avatar
 
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 211
Rep Power: 11
kandelabr is on a distinguished road
you need to slice your model into blocks. unfortunately with cavities, the number of blocks increases rapidly... but that's all i can help.

Unless you decide to use snappy/cfMesh and use blocks just to create geometry (inside): https://damogranlabs.com/2020/10/blo...xternal-flows/
__________________
www.damogranlabs.com
kandelabr is offline   Reply With Quote

Old   September 10, 2021, 16:01
Default
  #31
Member
 
Francisco T
Join Date: Nov 2011
Location: Melbourne, Australia
Posts: 64
Blog Entries: 1
Rep Power: 15
frantov is on a distinguished road
Thanks for your reply!

I want to avoid the stl creation for this case, therefore I think I will use blockMesh and a combination of
topoSet + subsetMesh commands to delete internal elements and create the cavity.

Cheers
kandelabr likes this.
frantov is offline   Reply With Quote

Old   July 10, 2023, 10:19
Default
  #32
Member
 
Pedro Gouveia
Join Date: Oct 2022
Location: Portugal
Posts: 65
Rep Power: 4
unilord is on a distinguished road
Hey,

I am working in Ubuntu 22.10, and I want to start using classy blocks to try and mesh the geometry in the atached picture. It is a turbopump, composed of a dual blade inducer, a radial impeller and a volute. The picture shown is of the fluid domain, not the actual pump solid.

https://imgur.com/a/WpltVGL

First question is, do you think that is doable or worth the time?

Second question, and excuse me for the ignorance. I can't get the examples to run in the python script. It is giving me the following error:

ModuleNotFoundError: No module named 'classy_blocks'

when I copy the https://github.com/damogranlabs/classy_blocks into the examples folders, it gives me this new error

https://github.com/damogranlabs/classy_blocks

So, could you please do a quick explanation/guide on how to proceed to the setup of classy blocks on ubuntu?
unilord is offline   Reply With Quote

Old   July 10, 2023, 16:11
Default
  #33
Senior Member
 
kandelabr's Avatar
 
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 211
Rep Power: 11
kandelabr is on a distinguished road
Hi, thank you for your interest in classy_blocks.

In fact, this whole thing started because I needed a better mesh for a centrifugal pump. I first wrote a simple script that tracked block points for me, then expanded it to what it is now. I do use classy_blocks to create a mesh of an impeller as part of my job so I can tell it is doable but cannot share the code. For me it was a huge success because I need a proper parametric model for automatic optimization but it took me around a year to whip it up (besides other nuisances I'm responsible for ). Can't imagine working without this now, though.

I use classy_blocks to to create a background mesh for a volute that fits inlet AMI ring and outlet mesh is oriented with the flow, but the spiral geometry is meshed with snappy. A volute can be meshed with pure-hexa blocks but at the moment I have no idea how. It's on my TODO list, though.

Inducer is probably the easiest part but also most probably not worth the time. Just use snappy and feed it a cylindrical background mesh.

About the examples: you probably didn't install the package correctly: see https://github.com/damogranlabs/clas...#how-to-use-it

You can PM me if you decide to dive into this... but you have been warned
__________________
www.damogranlabs.com
kandelabr is offline   Reply With Quote

Old   July 11, 2023, 04:13
Default
  #34
Member
 
Pedro Gouveia
Join Date: Oct 2022
Location: Portugal
Posts: 65
Rep Power: 4
unilord is on a distinguished road
Hey, thank you for the quick reply.

Honestly, after reading your point of view, I don't think it is worth the time at the moment. Mostly because I am working on my master thesis in partnership with a rocket company, so both me and them want to finish this kind of fast.

I liked your sugestion of the cylindrical background mesh. This is my first big CFD project, so I didn't even think about that possibility. I will implement that and let you know, in a few days/weeks how it turned out.

Thank you
unilord is offline   Reply With Quote

Old   July 11, 2023, 04:20
Default
  #35
Member
 
Pedro Gouveia
Join Date: Oct 2022
Location: Portugal
Posts: 65
Rep Power: 4
unilord is on a distinguished road
One question, the way you explained the stuff gave me the understanding that, usually, you mesh the components seperately. Is that right? If so, how do we make sure that the elements share the nodes between each other?
unilord is offline   Reply With Quote

Old   July 11, 2023, 05:58
Default
  #36
Senior Member
 
kandelabr's Avatar
 
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 211
Rep Power: 11
kandelabr is on a distinguished road
Yeah, if you need one mesh promptly, you need an automatic mesher. Try snappy and cfMesh, they will do the job.

In turbomachinery and other moving machinery you can't keep nodes together so static and moving mesh parts must be coupled in another way, AMI (ESI-CFD version), NCC (Foundation version) or GGI (foam-extend).

See the
Code:
incompressible/pimpleFoam/RAS/propeller
tutorial or similar to see what it looks like.
__________________
www.damogranlabs.com
kandelabr is offline   Reply With Quote

Old   March 13, 2025, 15:28
Default How chopping propagates in the custom sketch example
  #37
Member
 
Join Date: May 2020
Posts: 52
Blog Entries: 1
Rep Power: 6
Mars409 is on a distinguished road
Hi Nejc,

In classy_blocks, how does the chop specification propagate? Specifically, for instance, in the custom sketches example (https://damogranlabs.com/2024/11/cla...stom-sketches/), it is stated that

"Direction 0 :
Quad 0 will define all outer quads, that is 0 through 14" and

"Direction 1 :
Quad 0 will define 0, 3, and 2;
Quad 1 will define 1, 3, 16, 11, and 9;
Quads 4, 8 and 12 will define their respective corner buddies (which?? 7 & 6, 11 & 10, and 15 & 14??)". But this leaves out, 5, 7, 15, 16, 13.

Better to say this:
"Direction 1:
Quad 0 will define 0, 3, and 2; and Quads 4, 8 and 12 their respective corner buddies 7 & 6, 11 & 10, and 15 & 14; and along the two diagonals,
Quad 1 will define 1, 3, 16, 11, and 9; and Quad 5 will define 5, 7, 15, 16, 13."
Right?
Only then it makes sense to say in the example that defining variable chops = [[0], [0, 1, 4, 5, 8, 12]] is all it takes. Missing the statement about Quad 5 and its followers had made it very confusing for me before I figured this out.

How does the above get implemented? Which class method propagates the direction-1 chopping from Quad 1 to 3 and from Quad 3 to 16 and so on?

In fact, it seems defining the chopping on quad 0 directions 0 and 1 and quad 1 for direction 1 suffices to specify completely all the other quads by propagation, just by exploiting rotational symmetry. At this point, classy_blocks isn't doing this, right?

Am trying to go thru the Python codes to understand how it works. Please help.

Last edited by Mars409; March 13, 2025 at 16:43. Reason: To make it clearer.
Mars409 is offline   Reply With Quote

Old   March 13, 2025, 16:24
Default
  #38
Senior Member
 
kandelabr's Avatar
 
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 211
Rep Power: 11
kandelabr is on a distinguished road
Hello,

propagation first finds block edges (called 'Wires') that are coincident (shared between blocks). Coincident wires obviously have to be chopped identically but also wires within the same block must at least have the same cell count.

So if you take, for instance, block 0 from the tutorial sketch - this block has a wire from point 20 to point 0 (that's direction 0 for this block) and also 12-1 in the same direction. Block 1 also has that wire but this block's wire 13-2 must be chopped equally. This wire also touches block 2 and so on.

Block 0's direction 1 has wires 0-1 and 20-12 which is shared by blocks 3 and 2. In the same way, blocks 4, 7, 6 sit in the same row of wires and blocks 8, 11, 10 and 12, 15, 14.

When you do operation.chop() those parameters are stored and used when Operations are converted to Blocks. A Block has an Axis with 4 Wires in each direction. If there's a chop() (user-defined) available, the axis creates Grading objects and distributes it to its wires (items.wires.axis.Axis.grade()). If there's no chop(), it checks if any of their coincident blocks is already defined (items.wires.manager.WireManager.defined). If there is, wires are propagated from whatever was found. The same is repeated until all blocks have been graded properly (lists.block_list.BlockList.grade()).


Hope this helps, let me know if you need more detailed explanation of anything.
__________________
www.damogranlabs.com

Last edited by kandelabr; March 13, 2025 at 16:26. Reason: Bad CODE formatting
kandelabr is offline   Reply With Quote

Old   March 13, 2025, 16:46
Default
  #39
Member
 
Join Date: May 2020
Posts: 52
Blog Entries: 1
Rep Power: 6
Mars409 is on a distinguished road
Ah, that's really quick for you to reply. I just finished editing my early post then saw your reply. Will look at it now.
Mars409 is offline   Reply With Quote

Old   March 13, 2025, 17:13
Default
  #40
Member
 
Join Date: May 2020
Posts: 52
Blog Entries: 1
Rep Power: 6
Mars409 is on a distinguished road
Thank you for your detailed explanation. The first three paragraphs on how the grading propagation works matches my understanding. I guess, armed with this understanding, this is all I need to use classy_blocks to create arbitrary custom sketch. But now that I have embarked on better understanding, I figure I will look deeper and follow the ropes given in your 4th paragraph. Indeed, items directory is what I will dive into next. Thank you very much.

Last edited by Mars409; March 13, 2025 at 17:59. Reason: Deleting question I just found answer for.
Mars409 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[blockMesh] Creating an axisymmetric piston cylinder in blockMeshDict foadsf OpenFOAM Meshing & Mesh Conversion 10 Yesterday 07:06
[blockMesh] Created a python package for generating blockMeshDict grokkingStuff OpenFOAM Meshing & Mesh Conversion 3 November 5, 2020 07:55
[blockMesh] Creating a blockmeshDict file andrewlindsay OpenFOAM Meshing & Mesh Conversion 8 August 15, 2020 09:56
[blockMesh] what commands should I use to start creating a blockMeshdict file? Hojae OpenFOAM Meshing & Mesh Conversion 1 November 12, 2014 16:58
Possible Bug in pimpleFoam (or createPatch) (or fluent3DMeshToFoam) cfdonline2mohsen OpenFOAM 3 October 21, 2013 09:28


All times are GMT -4. The time now is 09:25.