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

objectRegistry::lookupObject<scalar>

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 25, 2013, 17:00
Default objectRegistry::lookupObject<scalar>
  #1
New Member
 
Tom Chyczewski
Join Date: Mar 2009
Location: Bethpage, New York, USA
Posts: 15
Rep Power: 17
chyczewski is on a distinguished road
(I have tried to add to an existing thread of the same title initiated by Brent Craven a couple years ago but don't seem to have been successful. I'm reposting here to cover my bases. Sorry for duplication, if any).


I have followed the procedure outlined in an earlier post (quoted at bottom) to update the boundary value in the course of a run and seem to have it working. But I get a warning message that is troubling me and I'd like to eliminate it. Here is the warning:

--> FOAM Warning :
From function Field<Type>::Field(const word& keyword, const dictionary&, const label)
in file /....../Field.C at line 262
Reading "myDict" from line 0 to line 0
expected keyword 'uniform' or 'nonuniform', assuming deprecated Field format from Foam version 2.0.

Here is my coding:
The dictionary is created in createFields.H:
Code:
IOdictionary myDict
(
     IOobject
     (
        "myDict",
        runTime.constant(),
        mesh,
        IOobject::NO_READ,
        IOobject::NO_WRITE
        )
);
The variable is set in my main loop
Code:
myDict.set("myValue",aeq[m][n]);
Finally, refValue is assigned the value of this variable in updateCoeffs() (I copied inletOutletFvPatchField and customized)
Code:
const dictionary& myDict = this->db().objectRegistry::lookupObject<IOdictionary>("myDict");
this->refValue() = Field<Type>("myValue",myDict,this->refValue().size());
If I print the value of refValue over the patch it changes appropriately with changes in m and n (used in the set command). So I think it is working properly. Does anyone know how to eliminate the warning or if it can be ignored? If it can be ignored, how do I suppress printing it? I took a look at line 262 of Field.C and get lost when it appears to be using a scalar as a boolean. Any help would be appreciated. Thanks.

Quote:
Originally Posted by brent_craven View Post
Yes. The methodology discussed by David above (http://www.cfd-online.com/Forums/ope...tml#post309556) worked well for me:

1. Declare the scalar as an IOobject
2. Calculate the scalar in your solver
3. Update the new scalar value with: scalarDict.set("nameOfScalar", valueOfScalar);
4. Access the new scalar value in your BC via a "db().lookupObject<IOdictionary>" (e.g., http://www.cfd-online.com/Forums/ope...tml#post309443)
chyczewski is offline   Reply With Quote

Old   November 26, 2013, 02:58
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
May I ask why you are using a dictionary, if you define the variable in the source code anyhow?
Bernhard is offline   Reply With Quote

Old   November 26, 2013, 08:09
Default
  #3
New Member
 
Tom Chyczewski
Join Date: Mar 2009
Location: Bethpage, New York, USA
Posts: 15
Rep Power: 17
chyczewski is on a distinguished road
Hi Bernhard,

My understanding is that this is a good way to bring a variable from the scope of the main solver into the boundary condition (following the discussion in the quoted thread). It is not practical to calculate this value within the boundary condition because a cubic equation needs to be solved at each point in wavenumber space to fill the array (aeq[m][n]) and it doesn't change over the course of the run. Also, I would have to bring a number of additional variables into the bc to do the calculation.
chyczewski is offline   Reply With Quote

Old   November 27, 2013, 12:36
Default
  #4
New Member
 
Tom Chyczewski
Join Date: Mar 2009
Location: Bethpage, New York, USA
Posts: 15
Rep Power: 17
chyczewski is on a distinguished road
Thanks to help from Dave Boger and Brent Craven, the solution was found to be replacing

Code:
myDict.set("myValue",aeq[m][n]);
with
Code:
std::stringstream strs;
strs<<"uniform "<< aeq[m][n];
myDict.set("myValue",strs.str().c_str()));
chyczewski 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



All times are GMT -4. The time now is 22:35.