CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   basicThermo.C in foam-extend-3.0, declared differently from OpenFOAM-1.6-ext (https://www.cfd-online.com/Forums/openfoam-programming-development/128557-basicthermo-c-foam-extend-3-0-declared-differently-openfoam-1-6-ext.html)

AlexC January 15, 2014 12:59

basicThermo.C in foam-extend-3.0, declared differently from OpenFOAM-1.6-ext
 
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.

dominik_christ January 16, 2014 12:28

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

AlexC January 16, 2014 13:16

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 January 16, 2014 13:37

RESOLVED!

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

Thanks again!


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