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

[blockMesh] Parametrizing BlockMesh (preferably without m4)

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By GerhardHolzinger

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 1, 2021, 05:19
Default Parametrizing BlockMesh (preferably without m4)
  #1
New Member
 
Join Date: Dec 2016
Posts: 24
Rep Power: 9
Dozer_94 is on a distinguished road
Hi everyone,

I have a tricky, maybe even impossible question.

The goal is to mesh a quarter (axisymmetric) cylinder with fixed length and radius L and R.
The cylinder wall is divided into N patches of equal length L/N (see the attached figure for N=5).

Right now I create vertices and blocks manually. You can imagine that if N becomes large, I can spend the entire day making a single mesh. Therefore, I'd like to parametrize N and let the script do it for me. The problem is that loops are not a thing in the BlockMeshDict (at least not to my knowing).

I know about m4 but the documentation is marginal. What is the best approach here?

Thanks in advance!
Attached Images
File Type: png qcylinder.PNG (21.5 KB, 12 views)
Dozer_94 is offline   Reply With Quote

Old   October 1, 2021, 05:28
Default
  #2
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 798
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Does this help: https://github.com/damogranlabs/classyBlocks
https://damogranlabs.com/2020/02/cla...for-blockmesh/
dlahaye is offline   Reply With Quote

Old   October 1, 2021, 08:55
Default
  #3
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 342
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
If you only want to use variable parameters, and don't need the entire magic that Python-scripting has to offer, you can also use OpenFOAM's on-board tools, i.e., using variables in dictionaries, the code-stream magic.

A parametric blockMeshDict from the tutorials
dlahaye likes this.
GerhardHolzinger is offline   Reply With Quote

Old   October 4, 2021, 06:53
Default
  #4
New Member
 
Join Date: Dec 2016
Posts: 24
Rep Power: 9
Dozer_94 is on a distinguished road
I downloaded the git and tried to run the "from_points" example, but python throws me a "raise AttributeError(f"Unknown edge type: {self.type}") on line 132 of primitives.py.

I installed and prioritized python 3.8 so not really sure where the error is originating from.

Quote:
If you only want to use variable parameters, and don't need the entire magic that Python-scripting has to offer, you can also use OpenFOAM's on-board tools, i.e., using variables in dictionaries, the code-stream magic.

A parametric blockMeshDict from the tutorials
I am considering this as well:

Code:
radius 			0.0005;
Len 			0.001;
nSegments 		5.0;

radHalfAngle    #calc "degToRad($halfAngle)";
y               #calc "$radius*sin($radHalfAngle)";
minY            #calc "-1.0*$y";
z               #calc "$radius*cos($radHalfAngle)";
segmentLength	#calc "$Len / $nSegments";

codeStream
#{
	std::array<float, $nSegments> lenarray;
	for (int i=1;i<$nSegments;i++)
	{
		lenarray[i] = $segmentLength*i;
	}
#};
Passing variables like "nSegments" into the codestream works fine, but how exactly can you return variables or other data like "lenarray" back to the regular code?
Dozer_94 is offline   Reply With Quote

Reply

Tags
blockmeshdict


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] OpenFOAM blockMesh bus error BRH OpenFOAM Meshing & Mesh Conversion 0 April 12, 2021 12:02
[OpenFOAM.org] blockMesh issue on openfoam6 startup - ubuntu 16.04 bjdarrer OpenFOAM Installation 7 August 25, 2020 20:15
Is Playstation 3 cluster suitable for CFD work hsieh OpenFOAM 9 August 16, 2015 15:53
[blockMesh] set of xyz data in blockMesh psk OpenFOAM Meshing & Mesh Conversion 12 August 27, 2013 09:37
Blockmesh cavity error message tonitoney OpenFOAM Installation 2 March 17, 2008 12:59


All times are GMT -4. The time now is 00:39.