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

Lookup autoPtr from fvMesh

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

Reply
 
LinkBack Thread Tools Display Modes
Old   January 21, 2011, 10:04
Default Lookup autoPtr from fvMesh
  #1
New Member
 
Misha Marie Gregersen
Join Date: Nov 2009
Posts: 7
Rep Power: 7
Misha is on a distinguished road
Dear openFOAM'ers

I am trying to access to the turbulence properties from a class where I have access to the mesh.

That is, in createFields.H I have:

singlePhaseTransportModel laminarTransport(U, phi);
autoPtr<incompressible::RASModel> turbulence
(
incompressible::RASModel::New(U, phi, laminarTransport)
);

And I would now like to access the pointer named "turbulence" from another class.

I thought it would be possible to access it in the way a dictionary can be accessed in another class, where the mesh has been passed and named mesh_:
dictionary transport = mesh_.lookupObject<IOdictionary>("transportPropert ies");

So what I need might be something like:
autoPtr<incompressible::RASModel> turbulence = mesh_.lookupObject<incompressible::RASModel>("turb ulence");

The expression above is of course not consistent, so I would appreciate any help or comments on how to access such a pointer from the objectRegistry!

Best regards
Misha
Misha is offline   Reply With Quote

Old   January 21, 2011, 10:43
Default
  #2
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 386
Rep Power: 15
deepsterblue will become famous soon enough
It appears that RASModel is derived from IOdictionary, which means that any turbulence model can be accessed by looking for it's typeName (like "kEpsilon", for instance). The (object).names() member function should give you a list of all objects currently registered with the mesh.

Also, any particular reason why you're looking for an autoPtr? Wouldn't a const reference to the object do the trick?
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue is offline   Reply With Quote

Old   January 24, 2011, 07:20
Default
  #3
New Member
 
Misha Marie Gregersen
Join Date: Nov 2009
Posts: 7
Rep Power: 7
Misha is on a distinguished road
Thank you for your answer!

I see that my pointer is not listed in mesh.names(), so I guess I cannot access it that way.

I want to be able to solve my equations using a member function in my new class;

Code:
 
void new_class::solveEqn()
{
volScalarField& U = const_cast<volScalarField&>(mesh_.lookupObject<volScalarField>("U")); surfaceScalarField& phi = const_cast<surfaceScalarField&>(mesh_.lookupObject<surfaceScalarField>("phi")); volScalarField& p = const_cast<volScalarField&>(mesh_.lookupObject<volScalarField>("p")); {
// (.... Standard SIMPLE code) tmp<fvVectorMatrix> UEqn ( fvm::div(phi, U) + turbulence->divDevReff(U) ); // (.... Standard SIMPLE code)
}
}
Having defined my autoPtr "turbulence" together with the fields U, phi, p in the createFields.H file I now want to access it in the member function of my class new_class as sketched above. So, I can figure out how to look up the fields U, phi and p, but I do not know how to access "turbulence".

My approach to the problem may be wrong - if so, I would really appreciate your comments!

~ Misha
Misha is offline   Reply With Quote

Reply

Tags
autoptr, lookupobject, objectregistry, rasmodel

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run time Selection Mechanism - Some help required to understand jaswi OpenFOAM Programming & Development 2 April 18, 2014 07:44
Convergence on anisotropic tetahedral meshes pbo OpenFOAM Running, Solving & CFD 12 December 14, 2010 12:59
face order in fvMesh constructor schmittp54 OpenFOAM Programming & Development 2 November 2, 2010 10:42
Error with 'vanAlbada' scheme Julian K. OpenFOAM Running, Solving & CFD 0 June 18, 2009 09:31
Buoyancydriven cavity flow anita OpenFOAM Running, Solving & CFD 3 March 26, 2008 11:24


All times are GMT -4. The time now is 17:49.