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 Community New Posts Updated Threads Search

Like Tree23Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 12, 2021, 18:25
Default
  #21
Senior Member
 
kandelabr's Avatar
 
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9
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, 17:56
Default
  #22
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 802
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, 55 views)
kandelabr likes this.
dlahaye is offline   Reply With Quote

Old   August 15, 2021, 19:10
Default
  #23
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 802
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, 16:04
Default
  #24
Senior Member
 
kandelabr's Avatar
 
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9
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, 16:26
Default
  #25
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 802
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, 06:09
Default
  #26
Senior Member
 
kandelabr's Avatar
 
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9
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, 07:59
Default
  #27
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 802
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, 17: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, 09: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, 29 views)
frantov is offline   Reply With Quote

Old   September 10, 2021, 11:46
Default
  #30
Senior Member
 
kandelabr's Avatar
 
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9
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, 17: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, 11:19
Default
  #32
Member
 
Pedro Gouveia
Join Date: Oct 2022
Location: Portugal
Posts: 64
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, 17:11
Default
  #33
Senior Member
 
kandelabr's Avatar
 
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9
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, 05:13
Default
  #34
Member
 
Pedro Gouveia
Join Date: Oct 2022
Location: Portugal
Posts: 64
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, 05:20
Default
  #35
Member
 
Pedro Gouveia
Join Date: Oct 2022
Location: Portugal
Posts: 64
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, 06:58
Default
  #36
Senior Member
 
kandelabr's Avatar
 
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9
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

Reply


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


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