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

Initializing reference variable of type objectRegistry

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 5, 2010, 16:05
Default Initializing reference variable of type objectRegistry
  #1
Senior Member
 
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 16
deji is on a distinguished road
Hey there foamers. I would like to initialize a reference variable of type objectRegistry and not so certain how to do that. In this line of code,
Code:
const Foam::compressible::LESModel & sgs = obr2.lookupObject<compressible::LESModel>("LESProperties");
obr2 is the reference variable of type objectRegistry. I initially defined a class and a constructor to help initialize it, but I am not quite getting it to work. Can anyone help?
deji is offline   Reply With Quote

Old   August 5, 2010, 16:39
Default
  #2
Senior Member
 
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 16
deji is on a distinguished road
so can i say something like:

const objectRegistry var1
const objectRegistry& obr2 = var1

so that i initialized obr2 ??


Thanks
Deji
deji is offline   Reply With Quote

Old   August 5, 2010, 20:19
Default
  #3
Senior Member
 
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 16
deji is on a distinguished road
i am still unable to get the initialization to work. there has to be someone on the forum that can help me with this question as i am not that experienced with OpenFOAM.
deji is offline   Reply With Quote

Old   August 6, 2010, 04:39
Default
  #4
Senior Member
 
Join Date: Mar 2009
Posts: 248
Rep Power: 18
jaswi is on a distinguished road
Hi Deji

There are some issues with that code line. You are basically using the
object lookup mechanism. You search for a type (i.e. class) of object. Here, if I am not wrong, you are looking up an object LESProperties of type IODictionary. In your code line there is no mention of the type of the object LESProperties. All you have is

const Foam::compressible::LESModel & sgs =
and that is nothing but namespaces. search forum for the keyword lookUpobject and you will find numerous examples on how to do that properly. If you will not get that right then please post the error as well so that we have more info.


Hope that helps
Jaswi
jaswi is offline   Reply With Quote

Old   August 6, 2010, 10:12
Default
  #5
Senior Member
 
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 16
deji is on a distinguished road
Hello Jaswi.

The error that I am getting states that: "obr_ was not defined in that scope"
Essentially, I would like to read the alphaEff and alpha field at the wall. I did try to read these quantities, but I saw that they were not defined in my constant folder that has the LESProperties dictionary. Should I add these variables to my LESProperties dictionary?

Thanks.

************************************Code********** **************************************************
1) const Foam::compressible::LESModel & sgs = obr_.lookupObject<compressible::LESModel>("LESProp erties");
2) const scalarField alphaEffw = sgs.alphaEff()().boundaryField()[patchK];
3) const scalarField alphaw = sgs.alpha().boundaryField()[patchK];

************************************Code********** **************************************************
deji is offline   Reply With Quote

Old   August 6, 2010, 10:36
Default
  #6
Senior Member
 
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 16
deji is on a distinguished road
By the way, Foam::compressible is a namespace that has the LESModel as a class contained within it.

Thanks.
deji is offline   Reply With Quote

Old   August 6, 2010, 12:06
Default
  #7
Senior Member
 
Join Date: Mar 2009
Posts: 248
Rep Power: 18
jaswi is on a distinguished road
Hi Deji

I still could not understand your question.
Aas far as i know LESProperties is an IOdictionary. If I want to read something directly from it then first I first create a reference to it like this:

const IOdictionary& myLesDict = mesh.lookupObject<IOdictionary>("LESProperties");

This will create the reference. To check that it really works, just write:

Info << myLesDict << endl;

It will print the whole dictionary on the screen.

you can also print just the part relevant to your model like this:

Info << myLesDict.subDict("smoothCoeffs") << endl;

then it just prints that part of the dictionary.

Perhaps you want to read some thing from the dictionary then you can add another subdictionary to the existing LESProperties, something like dejiCoeffs and put your values in it. For example i added at the end of my LESProperties

dejiCoeffs
{
myValue1 10;
myValue2 20.0;
}

and then

Info << myLesDict.subDict("dejiCoeffs") << endl;

prints these values from the dict.
In case you want to read these values into a variable then you will do like this:

const scalar myValue(readScalar(myLesDict.subDict("dejiCoeffs") .lookup("myValue1")));

Info << myValue << endl;

shall now print 10.

Hope this is what you were looking for. If not then please write again explaining what are the types of object you want to read becuase you say

Quote:
would like to read the alphaEff and alpha field at the wall.
if these variables are of type patchFields then I think LESProperties is not the right place to read in these fields.

Let us know a bit more and we will try to help you :-).
Regards
Jaswi

Last edited by jaswi; August 6, 2010 at 12:11. Reason: silly spelling mistakes :-)
jaswi is offline   Reply With Quote

Old   August 6, 2010, 12:30
Default
  #8
Senior Member
 
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 16
deji is on a distinguished road
Thanks for your replies Jaswi. You are right, that those quantities (alphaEff and alpha) are not in the LESProperties dictionaries. I checked the doxygen sourceguide and they are volScalarFields.

Well, I am writing a post-processor to compute the Nusselt # along the wall in a turbulent free convection flow. And, the Nusselt # is a function of alphaEff and alpha amongst other variables, and I am trying to read these values at the wall. And, I did verify that they cannot be in the LESProperties dictionary. Thanks.

Best regards
Deji
deji is offline   Reply With Quote

Old   August 6, 2010, 14:50
Default
  #9
Senior Member
 
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 16
deji is on a distinguished road
i was looking into this an discovered that this:
virtual tmp<volScalarField> alphaEff , so since alphaEff is a temporary object, and is destroyed during the simulation, does that mean that i cannot i basically cannot read such quantities for my post-processor ?

Thanks
Deji
deji 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
Segmentation Fault in fluent3DMeshToFoam cwang5 OpenFOAM Bugs 23 April 13, 2011 16:37
buoyantSimpleRadiationFoam msarkar OpenFOAM 0 February 15, 2010 07:22
[Other] StarToFoam error Kart OpenFOAM Meshing & Mesh Conversion 1 February 4, 2010 05:38
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 21:09


All times are GMT -4. The time now is 09:24.