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

Question about db().lookupObject<volScalarField>

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By user92
  • 1 Post By simrego
  • 1 Post By simrego

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 18, 2020, 05:17
Default Question about db().lookupObject<volScalarField>
  #1
New Member
 
Join Date: Nov 2020
Posts: 6
Rep Power: 5
user92 is on a distinguished road
Hello everyone,

I have a question about the line of code below which I found here in Line 84


const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");

I couldn't find a clear explanation for it, so I supposed that db stands for a database in OpenFOAM? and the code is looking for "p" in <volScalarField>

I suppose further that <volScalarField> must come from an .H file which has "p" ... is this right? if yes, is the file volScalarField.H available somewhere?

Thank you
CorbinMG likes this.

Last edited by user92; November 18, 2020 at 07:16.
user92 is offline   Reply With Quote

Old   November 18, 2020, 06:47
Default
  #2
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Hi!


after the "database" (db) is accessed, read like this: you are looking for an object (lookupObject), which is a volScalarField type (<volScalarField>), and called p ("p").

volScalarField is a typedef, it is a "shorter notation" of GeometricField<scalar, fvPatchField, volMesh>
It is defined here:
https://openfoam.com/documentation/g...ce.html#l00059
user92 likes this.
simrego is offline   Reply With Quote

Old   November 18, 2020, 07:55
Default
  #3
New Member
 
Join Date: Nov 2020
Posts: 6
Rep Power: 5
user92 is on a distinguished road
Quote:
Originally Posted by simrego View Post
Hi!


after the "database" (db) is accessed, read like this: you are looking for an object (lookupObject), which is a volScalarField type (<volScalarField>), and called p ("p").

volScalarField is a typedef, it is a "shorter notation" of GeometricField<scalar, fvPatchField, volMesh>
It is defined here:
https://openfoam.com/documentation/g...ce.html#l00059

Thank you I have a few more clarifications if I may ask

- I wonder if there is a link to the db where I can see all objects there including "p"?

- does <...> always describe types? or is it only a syntax for lookupObject<type>("object name")?

for example what you mentioned: GeometricField<scalar, fvPatchField, volMesh> ... does this mean that scalar, fvPatchField, volMesh are also types since they are inside <>? if yes, is is fine to have multiple types (3 in this case)?
user92 is offline   Reply With Quote

Old   November 18, 2020, 08:23
Default
  #4
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
You can read a bit about the objectRegistry here:
https://openfoamwiki.net/index.php/O...objectRegistry


And for the <> stuff, this is called templating. You should dig into the C++ programming language for details.
user92 likes this.
simrego is offline   Reply With Quote

Old   April 13, 2021, 07:06
Default
  #5
New Member
 
rocco
Join Date: Nov 2020
Posts: 13
Rep Power: 5
rocco96 is on a distinguished road
Hello everybody. I would like to use the pressure value calculated by my solver (internCondensatingEvaporatingfoam) within a library (constant.C). I tried to recall it as you recommend in this post, but the solver gives errors. As I understand it I should call the p object, but any way I use to call it doesn't work. Would anyone know how to give me some advice? I don't know what to put here const volScalarField & p = <???>. LookupObject <volScalarField> ("p");

Best Regards,
Rocco
rocco96 is offline   Reply With Quote

Reply


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
Question about symmetry in Autodesk Cfd 2016 ecto Autodesk Simulation CFD 0 October 20, 2015 04:16
small question about the functionalities of topological changes in OpenFoam ngj OpenFOAM Running, Solving & CFD 2 February 28, 2013 10:02
Question Re Engineering Data Source imnull ANSYS 0 March 5, 2012 13:51
internal field question - PitzDaily Case atareen64 OpenFOAM Running, Solving & CFD 2 January 26, 2011 15:26
Poisson Solver question Suresh Main CFD Forum 3 August 12, 2005 04:37


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