CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Writing c++ for loops in sampleDict file

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By arieljeds

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 14, 2016, 08:43
Default Writing c++ for loops in sampleDict file
  #1
Senior Member
 
ArielJ
Join Date: Aug 2015
Posts: 127
Rep Power: 11
arieljeds is on a distinguished road
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]);
    }
And then following this, I planned to set up the points like this:

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!
Bosen likes this.
arieljeds is offline   Reply With Quote

Reply

Tags
c++, for loop, sampledict


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
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


All times are GMT -4. The time now is 15:37.