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

An error about "const volVectorField& U = db().lookupObject<volVectorField>("U");"

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By ThomasV

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 2, 2014, 03:40
Default An error about "const volVectorField& U = db().lookupObject<volVectorField>("U");"
  #1
New Member
 
Zhiyuan Li
Join Date: Aug 2013
Location: Beijing
Posts: 9
Rep Power: 13
babala is on a distinguished road
Hello everyone,
I'm try to write a new pressure BC in OpenFoam.In this BC, I need to use velocity. So I use the code
"const volVectorField& U = db().lookupObject<volVectorField>("U");"
to get the information of U into the BC.
The BC has been compiled successfully. but when I use it in a case, the solver show an error below:
--------------------------------------------------------------------
Reading field p

--> FOAM FATAL ERROR:
request for volVectorField U from objectRegistry region0 failed
available objects of type volVectorField are
0
(
)

From function objectRegistry::lookupObject<Type>(const word&) const
in file /home/lizhy1/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 164.
FOAM aborting
----------------------------------------------------------------------
I don't know how to solve this problem. Please Help me!
Any help will be appreciated.
babala is offline   Reply With Quote

Old   December 3, 2014, 04:25
Default
  #2
Member
 
Thomas Vossel
Join Date: Aug 2013
Location: Germany
Posts: 45
Rep Power: 13
ThomasV is on a distinguished road
While I cannot help as I'm introducing myself into writing BCs too I'd like to extend the question. When looking at OpenFoam's code one can find segments like this:
Code:
const fvPatchScalarField& kp =
 patch().lookupPatchField<volScalarField, scalar>(kName_);
What are those private "kName_" obejcts needed for? It's basically just this...

Code:
//- Name of the turbulent kinetic energy field                                        word
  word kName_;
... and it's defined in the constructors like this:

Code:
kName_(dict.lookupOrDefault<word>("k", "k"))
So can't we just look up the values like it's described in the opening posting of this thread and have to use words and a lookup<word> method for this instead?
atulkjoy likes this.
ThomasV 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
const volVectorField& U = db().lookupObject<volVectorField>("U") gives runtime error kumar2 OpenFOAM Programming & Development 6 March 9, 2020 01:01


All times are GMT -4. The time now is 00:47.