|
[Sponsors] |
Initializing reference variable of type objectRegistry |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 5, 2010, 16:05 |
Initializing reference variable of type objectRegistry
|
#1 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
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"); |
|
August 5, 2010, 16:39 |
|
#2 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
so can i say something like:
const objectRegistry var1 const objectRegistry& obr2 = var1 so that i initialized obr2 ?? Thanks Deji |
|
August 5, 2010, 20:19 |
|
#3 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
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.
|
|
August 6, 2010, 04:39 |
|
#4 |
Senior Member
Join Date: Mar 2009
Posts: 248
Rep Power: 18 |
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 |
|
August 6, 2010, 10:12 |
|
#5 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
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********** ************************************************** |
|
August 6, 2010, 10:36 |
|
#6 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
By the way, Foam::compressible is a namespace that has the LESModel as a class contained within it.
Thanks. |
|
August 6, 2010, 12:06 |
|
#7 | |
Senior Member
Join Date: Mar 2009
Posts: 248
Rep Power: 18 |
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:
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 :-) |
||
August 6, 2010, 12:30 |
|
#8 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
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 |
|
August 6, 2010, 14:50 |
|
#9 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
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 |
|
|
|
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 |