|
[Sponsors] | |||||
Trying to create a range of values in openFoam c file |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|
|
#1 |
|
New Member
Nadeem Kever
Join Date: Jul 2019
Posts: 4
Rep Power: 8 ![]() |
Hi all,
I'm trying to do something very simple, but am not sure how to go about it. Essentially, here's what I need to do: first create a range of values then do a for loop over that range. In matlab, it would look something like this: Code:
x1 = 1; %Start
x2 = 3; %end
n = 5; %number of steps
y = linspace(x1,x2,n); % creates the range between z1 and x2 in n steps
for i = y
i
end
Code:
tmp = 0;
x1 = 1; //Start
x2 = 3; //end
n = 5; //number of steps
y = RANGE(x1,x2,n); // pseudocode for range <-- What goes here to create the range??
for (int i = 0; i < n; i ++){
tmp = y[i]
// do stuff with tmp val here
}
Thanks for any help! Last edited by NKever; January 1, 2023 at 09:38. |
|
|
|
|
|
![]() |
| Tags |
| c++, for loop, ranges |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using PengRobinsonGas EoS with sprayFoam | Jabo | OpenFOAM Running, Solving & CFD | 36 | July 16, 2024 04:52 |
| [OpenFOAM.com] swak4foam compiling issues on a cluster | saj216 | OpenFOAM Installation | 5 | January 17, 2023 17:05 |
| OpenFoam "Permission denied" and "command not found" problems. | iyidaniel@yahoo.co.uk | OpenFOAM Running, Solving & CFD | 11 | January 2, 2018 07:47 |
| [swak4Foam] funkySetFields compilation error | tayo | OpenFOAM Community Contributions | 39 | December 3, 2012 06:18 |
| "parabolicVelocity" in OpenFoam 2.1.0 ? | sawyer86 | OpenFOAM Running, Solving & CFD | 21 | February 7, 2012 12:44 |