|
[Sponsors] |
[blockMesh] How can I define functions with m4? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 21, 2014, 11:07 |
How can I define functions with m4?
|
#1 |
New Member
Olivia Nalen
Join Date: Apr 2014
Location: Vancouver
Posts: 19
Rep Power: 12 |
Dear OF-Users,
I'm trying to create a blockMeshDict with m4. I need to define all coordinates on the Z-axis as functions of coordinates on the X-axis. So far my m4-code looks like this: define (x1, 7) define (x2, 5) ... define (x20, 4) define (z1, calc(x1*2+1)) define (z2, calc(x2*2+1)) ... define (z20, calc(x20*2+1)) etc. And the problem is, I have about 100 coordinates and it is a bit awkward to define all 100 coordinates one by one. Maybe can somebody tell me how can I just once define a function for all Z-coordinates, if it's possible? Best regards, Olivia |
|
August 13, 2014, 10:38 |
|
#2 |
Senior Member
Join Date: Mar 2010
Location: Germany
Posts: 154
Rep Power: 16 |
Hi,
you could use any scripting or programming language to write the contents of the blockMeshDict. For example the following Python script Code:
#!/usr/bin/env python def func(x): return x*2.+1. def main(): for i in range(0, 11): x = .1*i z = func(x) print 'x{} {};'.format(i,x) print 'z{} {};'.format(i,z) if __name__ == "__main__": main() Code:
x0 0.0; z0 1.0; x1 0.1; z1 1.2; x2 0.2; z2 1.4; x3 0.3; z3 1.6; x4 0.4; z4 1.8; x5 0.5; z5 2.0; x6 0.6; z6 2.2; x7 0.7; z7 2.4; x8 0.8; z8 2.6; x9 0.9; z9 2.8; x10 1.0; z10 3.0; |
|
August 13, 2014, 11:00 |
|
#3 |
Senior Member
Join Date: Mar 2010
Location: Germany
Posts: 154
Rep Power: 16 |
The above post was just a workaround for your problem. Regarding your initial question on m4, maybe the following link helps:
http://www.slac.stanford.edu/comp/un...nfo/m4_11.html |
|
Tags |
functions, mesh |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
udf-Surface Reaction Rate-parse error in line 34 | priya_1985 | FLUENT | 1 | November 10, 2014 03:48 |
Wall functions | ivan-s | Main CFD Forum | 0 | August 25, 2014 13:35 |
udf explaination | Ijaz | Fluent UDF and Scheme Programming | 4 | May 8, 2012 05:24 |
UDF problem | libia87 | Fluent UDF and Scheme Programming | 1 | May 4, 2012 22:49 |
UDF carbon conversion | papteo | Fluent UDF and Scheme Programming | 1 | August 18, 2011 08:32 |