CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

List of scalars

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 11, 2017, 16:28
Default List of scalars
  #1
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15
gaza is on a distinguished road
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())

 {}
I wrote something like this:
Code:
const Foam::List<Foam::scalar> myList { std::initializer_list<Foam::scalar> { -0.00470863592031444,  -0.00472766747475117 } };
however it does not work.
Can anybody paste correct code here?
__________________
best regards
pblasiak
gaza is offline   Reply With Quote

Old   October 12, 2017, 14:33
Default
  #2
Senior Member
 
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 148
Rep Power: 9
Marpole is on a distinguished road
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 });
Marpole is offline   Reply With Quote

Old   October 12, 2017, 15:30
Default
  #3
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15
gaza is on a distinguished road
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};
but I want scalars and use List.
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
gaza is offline   Reply With Quote

Old   October 12, 2017, 15:57
Default
  #4
Senior Member
 
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 148
Rep Power: 9
Marpole is on a distinguished road
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;
Marpole is offline   Reply With Quote

Old   October 13, 2017, 02:36
Default
  #5
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15
gaza is on a distinguished road
I am using OF v1606
So how can I do what I want?
I do not want to use this constructor
Code:
List(Istream&);
because I will use it a lot so I want the fastest method.
__________________
best regards
pblasiak
gaza is offline   Reply With Quote

Old   October 13, 2017, 07:26
Default
  #6
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15
gaza is on a distinguished road
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
gaza is offline   Reply With Quote

Reply


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


All times are GMT -4. The time now is 08:00.