|
[Sponsors] |
January 31, 2008, 22:10 |
I have to store and manipulate
|
#1 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
I have to store and manipulate an array of 15 scalars in each cell. These scalars should be passed to other functions and saved to file.
Is there a fast or pre-defined way to do something similar in OF? With kind regards, Alberto
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
|
February 1, 2008, 00:19 |
While trying to solving this i
|
#2 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
While trying to solving this issue, I was thinking to use an IOPtrList, but I meet issues when I try to create a function which returns it.
In other words a function like: tmp<ioptrlist<volscalarfield> > myFunc() which returns an IOPtrList. Is this doable? Regards, Alberto
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
|
February 1, 2008, 03:10 |
Hi Alberto,
In reply to you
|
#3 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40 |
Hi Alberto,
In reply to your first post: if you want 15 scalars for each cell, why not define the corresponding class - eg, AlbertoScalars and pass that through? Instead of using volScalarField, which is acually GeometricField<scalar,>, you could have a volAlbertoField: GeometricField<albertoscalars,>. In reply to your second post: I don't think there are any restriction on what the tmp class can handle, but I would think you might be better having a PtrList instead of an IOPtrList and hook in the IOPtrList elsewhere from your tmp. /mark |
|
February 1, 2008, 12:35 |
Hello Mark,
I thought of us
|
#4 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
Hello Mark,
I thought of using volScalarFields because at a certain point I've to solve for them. I will try your suggestion to use PtrList instead of IOPtrList, and if it doesn't work I'll reconsider your idea of the class for my scalars. Thanks a lot, Alberto
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
|
February 1, 2008, 12:55 |
Using PtrList I get the same i
|
#5 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
Using PtrList I get the same issue I get with IOPtrList.
The compiler outputs the following: /home/alberto/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/PtrList.C: In copy constructor 'Foam::PtrList<t>::PtrList(const Foam::PtrList<t>&) [with T = Foam::GeometricField<double,>]': collisionModel/BGK/bgkCollision.C:123: instantiated from here /home/alberto/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/PtrList.C:61: error: invalid conversion from 'Foam::DimensionedField<double,>*' to 'Foam::GeometricField<double,>*' /home/alberto/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/tmpI.H: In destructor 'Foam::tmp<t>::~tmp() [with T = Foam::PtrList<foam::geometricfield<double,> >]': collisionModel/BGK/bgkCollision.C:123: instantiated from here /home/alberto/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/tmpI.H:82: error: 'class Foam::PtrList<foam::geometricfield<double,> >' has no member named 'okToDelete' /home/alberto/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/tmpI.H:89: error: 'class Foam::PtrList<foam::geometricfield<double,> >' has no member named 'operator--' /home/alberto/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/tmpI.H: In copy constructor 'Foam::tmp<t>::tmp(const Foam::tmp<t>&) [with T = Foam::PtrList<foam::geometricfield<double,> >]': collisionModel/BGK/bgkCollision.C:123: instantiated from here /home/alberto/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/tmpI.H:65: error: 'class Foam::PtrList<foam::geometricfield<double,> >' has no member named 'operator++' when I declare: tmp<ptrlist<volscalarfield> > myFunc ( const PtrList<volscalarfield>& m, const scalar& timeStep, const scalar& p ) const; and then define it as: Foam::tmp<foam::ptrlist<foam::volscalarfield> > Foam::myModel::myFunc ( const PtrList<volscalarfield>& m, const scalar& timeStep, const scalar& p ) const { /* cut code */ PtrList<volscalarfield> myList = m; /* Other code here */ return myList; } (Sorry if caps are not right, I copy and pasted, and it seems they went lost somewhere). Any ideas? :-) Thanks in advance, Alberto
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
|
February 1, 2008, 13:16 |
Just a bit more feedback. If I
|
#6 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
Just a bit more feedback. If I remove tmp<...>, I just get the invalid conversion error in the copy constructor:
/home/alberto/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/PtrList.C:61: error: invalid conversion from 'Foam::DimensionedField<double,>*' to 'Foam::GeometricField<double,>*' Looks strange to me, because both are PtrList<volscalarfield>. Regards, Alberto
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
|
February 1, 2008, 14:21 |
I can't really see what has go
|
#7 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40 |
I can't really see what has gone wrong here (still being very at C++), but since GeometricField is derived from DimensionedField, it looks like you are getting close.
Until you get it figured out, you might try cheating and just pass about Field\<scalar\> instead. |
|
February 1, 2008, 14:29 |
What's funny is that it _must_
|
#8 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
What's funny is that it _must_ be something under my eyes, because something similar to what I need is done in the sources of the code for example for species transport.
I just can't find an example of how a PtrList is passed as argument to a function, and then returned in some way. However I'll investigate it furtherly, because using a PtrList makes the code a lot more clean and readable, and keeps it consistent with the algorithm I want to implement. I'll make you know what I find. Alberto
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
|
February 1, 2008, 15:04 |
It seems there's something not
|
#9 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
It seems there's something not working properly to me. For example, if you write the simple lines:
PtrList<volscalarfield> a(10); PtrList<volscalarfield> b = a; you get exactly the same error when you compile. A.
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
|
February 3, 2008, 13:38 |
Well, I was trying to do somet
|
#10 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
Well, I was trying to do something meaningless I guess.
I just need to pass the PtrList by reference, and then use it directly in the method. Regards, A.
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
|
September 25, 2011, 09:10 |
I want to define an array
|
#11 |
Member
|
Hi Alberto,
I need exactly the same. Indeed I want to compute species mole fraction and also species diffusion coefficient and use them in YEqn. I read you post and it was very interesting but there is one question, did you solve your problem? how did you define an array with specific variables in each cell? I really appreciate if you could help me! |
|
September 28, 2011, 00:23 |
|
#12 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
Hi,
it has been a while. I re-thought the implementation in order to use a PtrList of fields. Best, Alberto
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
|
October 4, 2017, 05:14 |
Stuck at same point
|
#13 |
New Member
Omar Osama Mohamed
Join Date: Nov 2014
Posts: 26
Rep Power: 11 |
Hello all,
I am stuck at the same point. could you kindly elaborate how you managed to pass this problem ? |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Question about Converting Vector Arrays to Regular Arrays | xiao | OpenFOAM Running, Solving & CFD | 0 | September 3, 2008 22:30 |
Problems of convergencia in arrays | Jussara Zanote | CFX | 3 | February 22, 2005 16:29 |
Arrays in Fortran & C | SwF | Main CFD Forum | 11 | January 14, 2005 07:43 |
about multidimensional arrays in C | Adriana | Main CFD Forum | 3 | June 29, 2003 16:37 |
on taylor's series and C++ arrays | yfyap | Main CFD Forum | 9 | June 22, 2001 13:24 |