|
[Sponsors] |
October 11, 2017, 16:28 |
List of scalars
|
#1 |
Senior Member
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15 |
Hi All,
I want to create a list of scalars with this constructor: Code:
template<class T> Foam::List<T>::List(std::initializer_list<T> lst) : List<T>(lst.begin(), lst.end(), lst.size()) {} Code:
const Foam::List<Foam::scalar> myList { std::initializer_list<Foam::scalar> { -0.00470863592031444, -0.00472766747475117 } }; Can anybody paste correct code here?
__________________
best regards pblasiak |
|
October 12, 2017, 14:33 |
|
#2 |
Senior Member
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 148
Rep Power: 9 |
First, scalar is scalar. In your code, you are using a vector. The way to call it will be as below.
Code:
List<vector> myVectorList(vector {-0.00470863592031444, -0.00472766747475117 }); |
|
October 12, 2017, 15:30 |
|
#3 |
Senior Member
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15 |
Hi Marpole,
Thank you for your reply, however I do not want a vector. I want to create something like raw array: Code:
double a[] = {1,2}; The number of scalars will be huge and it will be hard-coded, similarly to this solution for emissivePowerTable https://github.com/OpenFOAM/OpenFOAM...BodyEmission.C
__________________
best regards pblasiak |
|
October 12, 2017, 15:57 |
|
#4 |
Senior Member
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 148
Rep Power: 9 |
Hello,
I checked up List.H. In the constructors, I haven't found the one you mentioned. The constructors are listed below. Which version of openfoam are you using? Code:
// Constructors //- Null constructor inline List(); //- Construct with given size explicit List(const label); //- Construct with given size and value for all elements List(const label, const T&); //- Construct with given size initializing all elements to zero List(const label, const zero); //- Copy constructor List(const List<T>&); //- Construct by transferring the parameter contents List(const Xfer<List<T>>&); //- Construct as copy or re-use as specified List(List<T>&, bool reuse); //- Construct as subset List(const UList<T>&, const labelUList& mapAddressing); //- Construct as copy of FixedList<T, Size> template<unsigned Size> explicit List(const FixedList<T, Size>&); //- Construct as copy of PtrList<T> explicit List(const PtrList<T>&); //- Construct as copy of SLList<T> explicit List(const SLList<T>&); //- Construct as copy of UIndirectList<T> explicit List(const UIndirectList<T>&); //- Construct as copy of BiIndirectList<T> explicit List(const BiIndirectList<T>&); //- Construct from Istream List(Istream&); //- Clone inline autoPtr<List<T>> clone() const; |
|
October 13, 2017, 02:36 |
|
#5 |
Senior Member
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15 |
I am using OF v1606
So how can I do what I want? I do not want to use this constructor Code:
List(Istream&);
__________________
best regards pblasiak |
|
October 13, 2017, 07:26 |
|
#6 |
Senior Member
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15 |
Ok thanks, I was using doxygen for v1706 and I did not check the code. In v1606 this constructor does not exist.
But can you tell mi how to create a list of scalars without Istream constructor?
__________________
best regards pblasiak |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] funkyDoCalc with OF2.3 massflow | NiFl | OpenFOAM Community Contributions | 14 | November 25, 2020 03:30 |
[foam-extend.org] Problems installing foam-extend-4.0 on openSUSE 42.2 and Ubuntu 16.04 | ordinary | OpenFOAM Installation | 19 | September 3, 2019 18:13 |
[Other] How to use finite area method in official OpenFOAM 2.2.0? | Detian Liu | OpenFOAM Meshing & Mesh Conversion | 4 | November 3, 2015 03:04 |
[foam-extend.org] problem when installing foam-extend-1.6 | Thomas pan | OpenFOAM Installation | 7 | September 9, 2015 21:53 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 17:51 |