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

lookup non included scalars from a list

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 11, 2012, 02:34
Default lookup non included scalars from a list
  #1
Member
 
Hossein
Join Date: Apr 2010
Posts: 65
Rep Power: 16
atoof is on a distinguished road
Send a message via Yahoo to atoof
Hi,

I need to lookup a list from a dictionary composed such as follows:

c_vs_w
100
(
( 0 0.001)
( 0.01 0.001)
( 0.02 0.001)
( 0.03 0.001)
.
.
.
)

I want to access to second values of above list by looking up the first values. During the run, it should be looked up non-included scalar from the list (finding corresponding value of 0.015 ,for instance). Can someone suggest me how to do it?
I study different utility and application such as interpolateXY, interpolationTable , etc.

Thank you in advance,
Moha
atoof is offline   Reply With Quote

Old   August 11, 2012, 07:30
Default
  #2
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Quote:
Originally Posted by atoof View Post
Hi,

I need to lookup a list from a dictionary composed such as follows:

c_vs_w
100
(
( 0 0.001)
( 0.01 0.001)
( 0.02 0.001)
( 0.03 0.001)
.
.
.
)

I want to access to second values of above list by looking up the first values. During the run, it should be looked up non-included scalar from the list (finding corresponding value of 0.015 ,for instance). Can someone suggest me how to do it?
I study different utility and application such as interpolateXY, interpolationTable , etc.

Thank you in advance,
Moha
Hello

Your post is not really sufficient for you to get help. I suggest you give more details:
http://www.cfd-online.com/Forums/ope...-get-help.html

I think you can take a look at:
Code:
tmp<Field<Type> > timeVaryingMappedFixedValueFvPatchField<Type>::interpolate)
in the C++ doc.

Regards
Hisham
Hisham is offline   Reply With Quote

Old   August 13, 2012, 01:05
Default
  #3
Member
 
Hossein
Join Date: Apr 2010
Posts: 65
Rep Power: 16
atoof is on a distinguished road
Send a message via Yahoo to atoof
Dear Hisham,

Thanks for reply. Indeed, in my simulation, I obtain a passive scalar (b) by solving a transport equation in a field with a certain U and P. Then I need to interpolate scalars from a table as a source term (W) by the value of "b" and send it to a solver. This lookup table consists of lists such as
100
(
(b1 w1)
(b2 w2)
(b3 w3)
(b4 w4)
.
.
.
)
.
I need to reach a "W" which is corresponding with a "b". My question is "How can this procedure be done?".

I studied timeVaryingMappedFixedValueFvPatchField but I don't know how to use it. I think this function in used for boundary condition. But I should find the source term in my entire field.

Best Regards
Hossein
atoof is offline   Reply With Quote

Old   August 13, 2012, 06:03
Default
  #4
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Dear Hossein,

I do not really know if such a possibility is actually available in OpenFOAM. I am sure someone must have implemented it before. The available interpolations are time interpolations or space interpolations over the mesh.

Nevertheless, introducing interpolation to the code in your case should not be difficult.

I think it may be interesting to take a look at other libraries for interpolation (to link to your solver):

gsl: http://www.gnu.org/software/gsl/
http://www.gnu.org/software/gsl/manu...rpolation.html

CGAL: http://www.cgal.org/Manual/latest/do...:Interpolation

A more careful search can yield better (more convenient) options.

Regards
Hisham
Hisham is offline   Reply With Quote

Old   August 13, 2012, 08:14
Default
  #5
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Hossein

You should be able to do something in the following way, where I assume you have the b and w coefficients as two scalarFields (the code below has not been tested).

Code:
// scalarField B = <KNOWN>
// scalarField W = <KNOWN>

// Your parameter b-simulation
scalar bSim(<some value>);

// Your source term w-simulation
scalar wSim( Foam::interpolateXY( bSim, B, W ) );
interpolateXY is a function and not an object, which I why you cannot construct it.

Furthermore, remember to include the following in your files:

Code:
#include "interpolateXY.H"
Please note that this yields a linear interpolation. If you need other types (higher order) interpolation scheme, then I am not sure if it is readably available in OF.

Kind regards,

Niels
ngj is offline   Reply With Quote

Old   August 14, 2012, 01:19
Default
  #6
Member
 
Hossein
Join Date: Apr 2010
Posts: 65
Rep Power: 16
atoof is on a distinguished road
Send a message via Yahoo to atoof
Thanks Niels,
It seems that I can implement it my code. I test it asp.
Code:
// scalarField B = <KNOWN>
// scalarField W = <KNOWN>
 
// Your parameter b-simulation
scalar bSim(<some value>);
 
// Your source term w-simulation
scalar wSim( Foam::interpolateXY( bSim, B, W ) );
But I have a file contains a list which includes both "b" and "w" such as my previous post. how can I define this list(of list) and access to it's member.

Best Regards,
Hossein
atoof is offline   Reply With Quote

Old   August 14, 2012, 02:25
Default
  #7
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
Hey,

are the lists of the same size as your mesh?

Best

Kathrin
kathrin_kissling is offline   Reply With Quote

Old   August 15, 2012, 07:21
Default
  #8
Member
 
Hossein
Join Date: Apr 2010
Posts: 65
Rep Power: 16
atoof is on a distinguished road
Send a message via Yahoo to atoof
Hello Kathrin,

Not necessarily. In my code, it has 100 members.

Sincerely yours,

Hossein
atoof is offline   Reply With Quote

Old   August 16, 2012, 16:53
Default
  #9
Member
 
Hossein
Join Date: Apr 2010
Posts: 65
Rep Power: 16
atoof is on a distinguished road
Send a message via Yahoo to atoof
Dears,
You should be able to do something in the following way, where I assume you have the b and w coefficients as two scalarFields (the code below has not been tested).

I read some other posts such as:
http://www.cfd-online.com/Forums/ope...tml#post308408
But I do not know the format of input files (X,Y,Xi in above code) to the code? and how can I read them through the code?

Thank you in advance,
Hossein
atoof is offline   Reply With Quote

Old   September 3, 2012, 07:31
Default Solved
  #10
Member
 
Hossein
Join Date: Apr 2010
Posts: 65
Rep Power: 16
atoof is on a distinguished road
Send a message via Yahoo to atoof
Dears,

Finally we find the solution. We Used the following for reeding scalars from two lists in a dictionary.
Code:
    IOobject dictHdr
    (
                    "listTestDict",
                    runTime.system(),
                    mesh,
                    IOobject::MUST_READ,
                    IOobject::NO_WRITE
     );

    IOdictionary dict(dictHdr);

    List<scalar> X(dict.lookup("X"));
    List<scalar> Y(dict.lookup("Y"));
atoof 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] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 16:02
friction forces icoFoam ofslcm OpenFOAM 3 April 7, 2012 10:57
CFX-Pre problem, pls help!!! cth_yao CFX 0 February 17, 2012 00:52
Convergence on anisotropic tetahedral meshes pbo OpenFOAM Running, Solving & CFD 12 December 14, 2010 11:59
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 16:35.