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

Transfer elements of dictionary into List<dimensionedScalar>

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 25, 2014, 13:07
Default Transfer elements of dictionary into List<dimensionedScalar>
  #1
Senior Member
 
Join Date: Jan 2012
Posts: 166
Rep Power: 14
maybee is on a distinguished road
hi,

in one of my files, let s call the file "properties" I have a subdict like

Code:
ValueV1
{
V1S1   [0 1 1 0 0 0 0] 888888;    
V1S2   [0 1 1 0 0 0 0] 7777;   
.                                //no constant number of entries
.
.
}
This subdict consists of dimensioned scalars where the number is not constant and can change. I need to transfer the dimensioned scalars into a list of dimensioned scalars -> "List<dimensionedScalar>"
I tried something like

Code:
List<dimensionedScalar> List_V1 = properties.subDict("ValueV1");
Unfortunately this does not work since

Code:
error: no match for ‘operator=’
Later on in my code I need to access the dimensioned scalars of the list by their element position - therefore I need the list.

I know that I can stream the subdict into an object of class dictionary or create a reference to it like

Code:
const dictionary& subDict = properties.subDict("Value1");
but how can I transfer the dimensioned scalars into a list afterwards?

greetings
maybee

Last edited by maybee; February 27, 2014 at 05:57.
maybee is offline   Reply With Quote

Old   February 26, 2014, 08:09
Default
  #2
Member
 
Join Date: Jul 2011
Posts: 54
Rep Power: 14
A_Pete is on a distinguished road
I would think that this is not possible since the subDict type has some other properties compared to the List type. Maybe you should try to run a forAll loop over the entries of the subDict and then assign them to a List<dimensioned scalar>. But are these really all entries of type dimensionedScalar?

If that is not possible then you can maybe just read the scalar values out of the subDict with the readScalar() function.

Can't guarantee that this works, but maybe something like this:

Code:
//Get name of dictionary before
List<dimensionedScalar> list(dict.size());
forAll(dictName, i)
{
     //Get name of actual entry before
     dimensionedScalar listElement = 
         (entryName, dimensionset(0, 1, 1, 0, 0, 0, 0), readScalar(properties.lookup(entryName)));
     list[i]=listElement;
}
Maybe you don't even need to assign to a dimensionedScalar first and can directly assign the value to list[i].
A_Pete is offline   Reply With Quote

Old   February 27, 2014, 05:55
Default
  #3
Senior Member
 
Join Date: Jan 2012
Posts: 166
Rep Power: 14
maybee is on a distinguished road
hi,

thx for the help. Unfortunately I can t use your code since the number of elements/entries within the subdict is not constant. Therefore I can t write the code using the list entries.
I edited my intitial quesiton now.

Edit: I guess I have found a solution that works like this:

Code:
wordList VALUES
    (
         properties.lookup("VALUES")
    );

forAll(VALUES, i) 
    {
        const word& Current = VALUES[i];
        dictionary& subDict_Values = properties.subDict("TheValues");
        List_Values[i] = dimensionedScalar(subDict_Values.lookup(Current));
    }
Guess this will work fine

greetings
maybee

Last edited by maybee; February 27, 2014 at 11:05.
maybee is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Heat transfer coefficient - what is waht Stan FLUENT 28 December 29, 2021 17:29
Fluent Tutorial on Heat transfer Far FLUENT 15 July 29, 2017 16:31
Question about heat transfer coefficient setting for CFX Anna Tian CFX 1 June 16, 2013 07:28
Convective Heat Transfer - Heat Exchanger Mark CFX 6 November 15, 2004 16:55
additional variable mass transfer in CFX5.6 john CFX 1 February 14, 2004 01:30


All times are GMT -4. The time now is 07:27.