|
[Sponsors] |
August 11, 2012, 02:34 |
lookup non included scalars from a list
|
#1 |
Member
|
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 |
|
August 11, 2012, 07:30 |
|
#2 | |
Senior Member
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17 |
Quote:
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) Regards Hisham |
||
August 13, 2012, 01:05 |
|
#3 |
Member
|
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 |
|
August 13, 2012, 06:03 |
|
#4 |
Senior Member
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17 |
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 |
|
August 13, 2012, 08:14 |
|
#5 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37 |
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 ) ); Furthermore, remember to include the following in your files: Code:
#include "interpolateXY.H" Kind regards, Niels |
|
August 14, 2012, 01:19 |
|
#6 |
Member
|
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 ) ); Best Regards, Hossein |
|
August 14, 2012, 02:25 |
|
#7 |
Senior Member
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17 |
Hey,
are the lists of the same size as your mesh? Best Kathrin |
|
August 15, 2012, 07:21 |
|
#8 |
Member
|
Hello Kathrin,
Not necessarily. In my code, it has 100 members. Sincerely yours, Hossein |
|
August 16, 2012, 16:53 |
|
#9 |
Member
|
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 |
|
September 3, 2012, 07:31 |
Solved
|
#10 |
Member
|
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")); |
|
|
|
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 |