CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

Field of arrays

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   January 31, 2008, 23:10
Default I have to store and manipulate
  #1
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,894
Rep Power: 26
alberto will become famous soon enoughalberto will become famous soon enough
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 live DVD/USB, hard drive image and virtual image.
OpenQBMM - An open-source implementation of quadrature-based moment methods
alberto is offline   Reply With Quote

Old   February 1, 2008, 01:19
Default While trying to solving this i
  #2
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,894
Rep Power: 26
alberto will become famous soon enoughalberto will become famous soon enough
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 live DVD/USB, hard drive image and virtual image.
OpenQBMM - An open-source implementation of quadrature-based moment methods
alberto is offline   Reply With Quote

Old   February 1, 2008, 04:10
Default Hi Alberto, In reply to you
  #3
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 777
Rep Power: 18
olesen will become famous soon enough
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
olesen is offline   Reply With Quote

Old   February 1, 2008, 13:35
Default Hello Mark, I thought of us
  #4
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,894
Rep Power: 26
alberto will become famous soon enoughalberto will become famous soon enough
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 live DVD/USB, hard drive image and virtual image.
OpenQBMM - An open-source implementation of quadrature-based moment methods
alberto is offline   Reply With Quote

Old   February 1, 2008, 13:55
Default Using PtrList I get the same i
  #5
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,894
Rep Power: 26
alberto will become famous soon enoughalberto will become famous soon enough
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 live DVD/USB, hard drive image and virtual image.
OpenQBMM - An open-source implementation of quadrature-based moment methods
alberto is offline   Reply With Quote

Old   February 1, 2008, 14:16
Default Just a bit more feedback. If I
  #6
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,894
Rep Power: 26
alberto will become famous soon enoughalberto will become famous soon enough
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 live DVD/USB, hard drive image and virtual image.
OpenQBMM - An open-source implementation of quadrature-based moment methods
alberto is offline   Reply With Quote

Old   February 1, 2008, 15:21
Default I can't really see what has go
  #7
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 777
Rep Power: 18
olesen will become famous soon enough
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.
olesen is offline   Reply With Quote

Old   February 1, 2008, 15:29
Default What's funny is that it _must_
  #8
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,894
Rep Power: 26
alberto will become famous soon enoughalberto will become famous soon enough
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 live DVD/USB, hard drive image and virtual image.
OpenQBMM - An open-source implementation of quadrature-based moment methods
alberto is offline   Reply With Quote

Old   February 1, 2008, 16:04
Default It seems there's something not
  #9
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,894
Rep Power: 26
alberto will become famous soon enoughalberto will become famous soon enough
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 live DVD/USB, hard drive image and virtual image.
OpenQBMM - An open-source implementation of quadrature-based moment methods
alberto is offline   Reply With Quote

Old   February 3, 2008, 14:38
Default Well, I was trying to do somet
  #10
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,894
Rep Power: 26
alberto will become famous soon enoughalberto will become famous soon enough
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 live DVD/USB, hard drive image and virtual image.
OpenQBMM - An open-source implementation of quadrature-based moment methods
alberto is offline   Reply With Quote

Old   September 25, 2011, 09:10
Default I want to define an array
  #11
Member
 
Yashar Afarin
Join Date: May 2010
Location: Toronto- Canada
Posts: 40
Rep Power: 7
yashar.afarin is on a distinguished road
Send a message via Skype™ to yashar.afarin
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!
yashar.afarin is offline   Reply With Quote

Old   September 28, 2011, 00:23
Default
  #12
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,894
Rep Power: 26
alberto will become famous soon enoughalberto will become famous soon enough
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 live DVD/USB, hard drive image and virtual image.
OpenQBMM - An open-source implementation of quadrature-based moment methods
alberto is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


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 17:29
Arrays in Fortran & C SwF Main CFD Forum 11 January 14, 2005 08: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


All times are GMT -4. The time now is 04:52.