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

basicThermo.C in foam-extend-3.0, declared differently from OpenFOAM-1.6-ext

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

Reply
 
LinkBack Thread Tools Display Modes
Old   January 15, 2014, 13:59
Default basicThermo.C in foam-extend-3.0, declared differently from OpenFOAM-1.6-ext
  #1
New Member
 
Alex Chan
Join Date: Jan 2014
Location: Amherst, MA
Posts: 10
Rep Power: 4
AlexC is on a distinguished road
Hello! I am porting a solver from OpenFOAM-1.6-ext to foam-extend-3.0. Looks like the basicThermo class is declared differently in $FOAM_SRC/thermophysicalModels/basic/basicThermo/basicThermo.C under ***Constructors***

OF-1.6-ext:
Foam::basicThermo::basicThermo(const fvMesh& mesh)

foam-extend-3.0:
Foam::basicThermo::basicThermo(const fvMesh& mesh, const objectRegistry& obj)

In my code before, I only needed "basicThermo(U.mesh())" but now I understand I need another argument that is from the objectRegistry. What should that be?

Also, excuse/feel free to correct my incorrect terminology - I am still learning the c++ jargon. Thanks!
----------
[edit]

forgot to mention that I tried using runTime as the objectRegistry variable(?). In my solver, I put in:

const objectRegistry& runTimeObjectRegistry

and

basicThermo(U.mesh(), runTimeObjectRegistry),

This allowed my solver to compile, but when I run a case it gives this result:

Quote:
--> FOAM FATAL ERROR:

request for volScalarField p from objectRegistry region0 failed
available objects of type volScalarField are

19
(
M
theta
... (omitted rest of this list)
y
)
From function objectRegistry::lookupObject<Type>(const word&) const
in file /home/achan/foam/foam-extend-3.0/src/foam/lnInclude/objectRegistryTemplates.C at line 139.
AlexC is offline   Reply With Quote

Old   January 16, 2014, 13:28
Default
  #2
New Member
 
Dominik Christ
Join Date: Mar 2009
Posts: 28
Rep Power: 9
dominik_christ is on a distinguished road
Hi Alex,

In your post you describe that you create runTimeObjectRegistry as a const reference, but where is the const reference pointing to? (The rest of the line is missing in your post.)
You get a run-time error because you created a new objectRegistry, which is empty and field "p" cannot be found there. What you want to do instead is provide access to the objectRegistry that is "in use" within your application and that has all the fields and dictionaries. You can grab it from the mesh object via mesh.thisDb() . But since mesh is of class fvMesh and fvMesh is derived from polyMesh which is derived from objectRegistry (Doxygen is your friend here and gives a nice picture showing the relationship), you can pass "mesh" as second argument as well and it will be automatically stripped down to an objectRegistry object.
So calling:
basicThermo(mesh,mesh)
should do the job.

Best regards,
Dominik
dominik_christ is offline   Reply With Quote

Old   January 16, 2014, 14:16
Default
  #3
New Member
 
Alex Chan
Join Date: Jan 2014
Location: Amherst, MA
Posts: 10
Rep Power: 4
AlexC is on a distinguished road
Thanks for the response! Unfortunately I'm not sure if I made the changes correctly. I changed the call to basicThermo as you suggested and when I compile, I get this:

Quote:
modelCal/modelCalc.C:57:17: error: ‘mesh’ was not declared in this scope
basicThermo(mesh,mesh),
So i tried instead:

basicThermo(mesh_,mesh_)

and it seems to compile correctly. When I run a case, I get a "segmentation fault".

On openfoamwiki.net, it says

Quote:
A segmentation fault usually occurs when a program trys to access memory outside its bounds (http://openfoamwiki.net/index.php/Ma...at_is_wrong.3F)
Does that mean that I need to reference a derived from mesh?
AlexC is offline   Reply With Quote

Old   January 16, 2014, 14:37
Default
  #4
New Member
 
Alex Chan
Join Date: Jan 2014
Location: Amherst, MA
Posts: 10
Rep Power: 4
AlexC is on a distinguished road
RESOLVED!

basicThermo(U.mesh(),U.mesh())

Thanks again!
AlexC is offline   Reply With Quote

Reply

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
CGNS converters available mbeaudoin OpenFOAM Meshing & Mesh Conversion 131 November 5, 2016 22:51
OpenFOAM 1.6 extend cmake bug CKH OpenFOAM Installation 0 December 30, 2011 05:28
cgnsToFoam problems with "QUAD_4" cells lentschi OpenFOAM Meshing & Mesh Conversion 1 March 9, 2011 05:49
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Native Meshers: blockMesh 10 April 2, 2007 14:00


All times are GMT -4. The time now is 06:41.