|
[Sponsors] |
June 10, 2014, 10:05 |
How to input a list
|
#1 |
New Member
Christopher Hughes
Join Date: Oct 2012
Posts: 27
Rep Power: 14 |
I am looking to create an equation of state library that uses tables instead of an equation to determine properties. I am pretty happy with the structure that I have; however, I cannot seem to get the syntax correct.
I am currently trying to enter a large set of 200 cell arrays into the main header file so that when I call the equation file (PerfectGasI.H for example) I don't have to load all the arrays, but will reference only the ones I need. I have currently tried the following: inline scalar cpa1[200] = ( # # # ....); inline scalar cpa1[200] = ( #,#,#,....); inline scalar cpa1[200] = { # # # ....}; inline scalar cpa1[200] = { #,#,#,....}; inline scalar cpa1[200] and then entering the values in the .C file. I have also tried double without the inline to know avail. After going through the errors, I'm pretty sure that the form inline scalar cpa1[200] = (# # # ...) is the closest to correct; however, I still get the following errors expected ‘)’ before numeric constant error: ISO C++ forbids initialization of member ‘cpa1’ [-fpermissive] error: making ‘cpa1’ static [-fpermissive] error: invalid in-class initialization of static data member of non-integral type ‘Foam::scalar [200] {aka double [200]}’ The array in question is reproduced below. inline scalar cpa1[200] = (3.97 3.9726 3.9752 3.9778 3.9804 3.983 3.9856 3.9882 3.9908 3.9935 3.9961 3.9988 4.0014 4.0041 4.0068 4.0094 4.0121 4.0148 4.0175 4.0202 4.0229 4.0256 4.0283 4.0311 4.0338 4.0365 4.0393 4.0421 4.0448 4.0476 4.0504 4.0532 4.0559 4.0587 4.0616 4.0644 4.0672 4.07 4.0729 4.0757 4.0786 4.0814 4.0843 4.0872 4.09 4.0929 4.0958 4.0987 4.1016 4.1046 4.1075 4.1104 4.1134 4.1163 4.1193 4.1222 4.1252 4.1282 4.1312 4.1342 4.1372 4.1402 4.1432 4.1463 4.1493 4.1524 4.1554 4.1585 4.1616 4.1646 4.1677 4.1708 4.1739 4.1771 4.1802 4.1833 4.1865 4.1896 4.1928 4.1959 4.1991 4.2023 4.2055 4.2087 4.2119 4.2151 4.2184 4.2216 4.2249 4.2281 4.2314 4.2347 4.238 4.2413 4.2446 4.2479 4.2512 4.2545 4.2579 4.2612 4.2646 4.268 4.2714 4.2748 4.2782 4.2816 4.285 4.2884 4.2919 4.2953 4.2988 4.3023 4.3058 4.3093 4.3128 4.3163 4.3198 4.3233 4.3269 4.3305 4.334 4.3376 4.3412 4.3448 4.3484 4.352 4.3557 4.3593 4.363 4.3666 4.3703 4.374 4.3777 4.3814 4.3852 4.3889 4.3926 4.3964 4.4002 4.404 4.4077 4.4116 4.4154 4.4192 4.423 4.4269 4.4308 4.4346 4.4385 4.4424 4.4464 4.4503 4.4542 4.4582 4.4621 4.4661 4.4701 4.4741 4.4781 4.4822 4.4862 4.4903 4.4943 4.4984 4.5025 4.5066 4.5108 4.5149 4.519 4.5232 4.5274 4.5316 4.5358 4.54 4.5442 4.5485 4.5527 4.557 4.5613 4.5656 4.5699 4.5743 4.5786 4.583 4.5874 4.5918 4.5962 4.6006 4.605 4.6095 4.6139 4.6184 4.6229 4.6274 4.632 4.6365 4.6411 4.6457 4.6502 4.6549); Should I initialize it as a vector (vector<double> cpa1(200); ) and then use cpa1.assign( # # # # ...)? Any help will be greatly appreciated. |
|
June 10, 2014, 10:47 |
|
#2 |
Senior Member
|
Hi,
http://www.cplusplus.com/doc/tutorial/arrays/ Can you show the error you get when you've used Code:
scalar cpa1[200] = { number1, number2, ... }; |
|
June 10, 2014, 10:59 |
|
#3 |
New Member
Christopher Hughes
Join Date: Oct 2012
Posts: 27
Rep Power: 14 |
error: a brace-enclosed initializer is not allowed here before ‘{’ token
error: ISO C++ forbids initialization of member ‘cpa1’ [-fpermissive] error: making ‘cpa1’ static [-fpermissive] error: invalid in-class initialization of static data member of non-integral type ‘Foam::scalar [200] {aka double [200]}’ I am using OpenFOAM 2.1.1 if that helps at all. adding static before scalar produces the following errors: error: a brace-enclosed initializer is not allowed here before ‘{’ token error: invalid in-class initialization of static data member of non-integral type ‘Foam::scalar [200] {aka double [200]}’ so that is a step in the right direction. |
|
June 10, 2014, 11:13 |
|
#4 |
New Member
Christopher Hughes
Join Date: Oct 2012
Posts: 27
Rep Power: 14 |
Fixed it. The issue was that the array has to be initialized in the class, but assigned a value outside of the class definition. Once this was done, the system compiled.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] funkyDoCalc with OF2.3 massflow | NiFl | OpenFOAM Community Contributions | 14 | November 25, 2020 04:30 |
[OpenFOAM] Paraview 3.98 - errors when saving geometry file | pajot | ParaView | 1 | September 28, 2013 11:45 |
[swak4Foam] Error bulding swak4Foam | sfigato | OpenFOAM Community Contributions | 18 | August 22, 2013 13:41 |
[swak4Foam] build problem swak4Foam OF 2.2.0 | mcathela | OpenFOAM Community Contributions | 14 | April 23, 2013 14:59 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 18:51 |