CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

How to change automatically parameters in blockMesh and run a parametric case

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 1 Post By Tobermory
  • 2 Post By dlahaye
  • 1 Post By HYJLEE

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 21, 2023, 12:48
Smile How to change automatically parameters in blockMesh and run a parametric case
  #1
New Member
 
Join Date: Sep 2023
Posts: 2
Rep Power: 0
Raffaele10 is on a distinguished road
Hello everyone!

I'd like to set an automatic parametric-iterative case changing some parameters in the blockMeshDict. Basically I have a set of geometic parameters on which the mesh depens, what I want to do is to change this parameters and run the simulation automatically. This is a conjugate heat transfer case (liquid-solid) and I want to find the best shape of some component in order the minimize the temperture of the solid.

The idea is:
1-generate n sets of geometric parameters;
2-run n simulations changing the n set of parameters;
3-write a file with the results for each case.

I'm pretty new to OpenFOAM, python and C++ and I don't know which one is the best approach, I know that some use pyFoam, other use DAKOTA.

Can someone suggest a good approch to perform this case or maybe provide a tamplate with a similar case?

Thanks !
Raffaele10 is offline   Reply With Quote

Old   September 21, 2023, 18:26
Default
  #2
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 747
Rep Power: 14
Tobermory will become famous soon enough
Sounds like a nice idea. The way I'd do it is as follows:
  1. - generate a template case folder with a system/blockMeshDict file with the parameters as you described, and an Allrun script to mesh, setup the model and then run the case (check out the tutorials for an example of an Allrun script)
  2. - generate a bash script file (this is basically what an Allrun script is) in the folder above; for each of the parameter sets you want to run, get the script to:
    • make a copy of the template folder, with a unique name
    • cd into that folder and run foamDictionary on blockMeshDict to update the parameter values
    • run the Allrun script, piping output into a local log file
    • execute any other postprocessing that you want to do (you should probably include that in the Allrun file)
  3. use a separate log file for the bash script to log the actions that the script has completed

etc. - hopefully you get the idea. You could try run from python, but IMO bash scripts are much simpler to use. Good luck!
Raffaele10 likes this.
Tobermory is offline   Reply With Quote

Old   September 22, 2023, 10:33
Default
  #3
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 802
Blog Entries: 1
Rep Power: 18
dlahaye is on a distinguished road
https://github.com/damogranlabs/classy_blocks ?
ancolli and Raffaele10 like this.
dlahaye is offline   Reply With Quote

Old   October 4, 2023, 11:47
Default
  #4
New Member
 
Join Date: Jul 2019
Posts: 2
Rep Power: 0
HYJLEE is on a distinguished road
Using .m4 file to make your parametrized blockMesh template would be helpful.

This page contains information of m4 file.
https://openfoamwiki.net/index.php/H...ckMesh_with_m4
refer to this page, you can make your own .m4 file

And then, modifying only 'value' of define(variable,value) in .m4 file automatically with some code(it can be based on C++, python, etc..)

If you successfully editted your .m4 file, command "m4 blockMeshDict.m4 > blockMeshDict;blockMesh" will construct mesh with changed parameters.

I hope it would be helpful to find your optimal solution using OpenFOAM.

ps. There are some examples on .m4 file in tutorials of foam-extend. Its m4 file is also can be used not only foam-extend but also OpenFOAM, when its boundary conditions are modified properlly.
Raffaele10 likes this.
HYJLEE 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
OpenFOAM benchmarks on various hardware eric Hardware 821 Yesterday 02:45
Displaying OpenFOAM Results Automatically in ParaView through a Single Command nucerl OpenFOAM Post-Processing 0 December 21, 2022 20:28
How to run the 3dTube case in parallel (foam-extend 3.1 with FSI from Zagreb)? Warlord OpenFOAM Running, Solving & CFD 1 January 27, 2018 15:48
Some questions about a multi region case run in parallel zfaraday OpenFOAM Running, Solving & CFD 5 February 23, 2017 11:25
[blockMesh] run BlockMesh in existing case? xiyuqiu OpenFOAM Meshing & Mesh Conversion 0 February 24, 2011 19:55


All times are GMT -4. The time now is 01:13.