|
[Sponsors] |
April 14, 2016, 08:43 |
Writing c++ for loops in sampleDict file
|
#1 |
Senior Member
ArielJ
Join Date: Aug 2015
Posts: 127
Rep Power: 11 |
Hi there,
I'm trying to write my sampleDict so that I can easily adjust the location of probes by changing one line (say, the diameter for a cylinder). I want to write a for loop that will loop through a theta value from 0 to 2*pi in steps of pi/16 (32 probes), and calculate the location of the probes. The bit of code I have so far is: Code:
r -3.05; //r2 -3.05; pi #calc "4.0*atan(1.000)"; p1 #calc "$r2*cos($pi/16)"; n 32; z -1.0; dtheta #calc "$pi/8"; theta[$n] {}; theta[0] = 0; for (i = 1; i == n; i++) { theta[$i] = theta[$i - ] + $dtheta; x[$i] = $r * cos(theta[$i]); y[$i] = $r * sin(theta[$i]); } Code:
cylinderProbes { type cloud; axis xyz; points ( ( $x[0] $y[0] $z ) ( $x[1] $y[1] $z ) ..... etc..... ) } This is, probably obviously, not working. I did something similar in my blockMeshDict, which worked out fine but now I'm getting errors (lots and lots of errors...) I know that I should be using C++ but I also know that Openfoam isn't quite C++, so I made some guesses about the syntax here. Can anyone offer some advice on how to do this?? Thanks in advance! |
|
Tags |
c++, for loop, sampledict |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to calculate mass flow rate on patches and summation of that during the run? | immortality | OpenFOAM Post-Processing | 104 | February 16, 2021 09:46 |
Trouble compiling utilities using source-built OpenFOAM | Artur | OpenFOAM Programming & Development | 14 | October 29, 2013 11:59 |
[swak4Foam] build problem swak4Foam OF 2.2.0 | mcathela | OpenFOAM Community Contributions | 14 | April 23, 2013 14:59 |
2.0.x on Mac OSX | niklas | OpenFOAM Installation | 74 | March 28, 2012 17:46 |
ParaView Compilation | jakaranda | OpenFOAM Installation | 3 | October 27, 2008 12:46 |