CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   unexpected call for rho in modified buoyantBoussinesqSimpleFoam (

romant April 13, 2012 04:58

unexpected call for rho in modified buoyantBoussinesqSimpleFoam

I have slightly modified buoyantBoussinesqSimpleFoam in order to implement a different way of calculating the temperature equation

Therefore the main file looks like this now

Info<< "\nStarting time loop\n" << endl;

    while (simple.loop())
        Info<< "Time = " << runTime.timeName() << nl << endl;

        // Pressure-velocity SIMPLE corrector
            #include "UEqn.H"
            #include "AHFMEqn.H" // new
            #include "TEqn.H"
            #include "pEqn.H"



        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;

    Info<< "End\n" << endl;

where the highlighted part is a new equation that calculates a field for the temperature equation. It compiles and the temperature equation is solved. As can be seen from the output

SIMPLE: convergence criteria
    field p_rgh    tolerance 1e-08
    field T    tolerance 1e-06
    field U    tolerance 1e-06

Starting time loop

Time = 1

DILUPBiCG:  Solving for Ux, Initial residual = 1, Final residual = 0.0281127014, No Iterations 1
DILUPBiCG:  Solving for Uy, Initial residual = 1, Final residual = 0.0281177952, No Iterations 1
DILUPBiCG:  Solving for theta2, Initial residual = 0.999994784, Final residual = 0.0182097574, No Iterations 1
DILUPBiCG:  Solving for T, Initial residual = 1, Final residual = 0.0280023891, No Iterations 1
do p_rghEqn setup


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

the "do p_rghEqn setup" comes from an info part that I now inserted into the pEqn.H part of the solver in order to find the error. For some unexplained reason the solver wants to look up rho in the pEqn.H part of the solver, even though that part is untouched as in


    volScalarField rAU("rAU", 1.0/UEqn().A());
    surfaceScalarField rAUf("(1|A(U))", fvc::interpolate(rAU));

    U = rAU*UEqn().H();

    phi = fvc::interpolate(U) & mesh.Sf();
    adjustPhi(phi, U, p_rgh);

    surfaceScalarField buoyancyPhi(rAUf*ghf*fvc::snGrad(rhok)*mesh.magSf());
    phi -= buoyancyPhi;

    while (simple.correctNonOrthogonal())
        Info << "do p_rghEqn setup\n" << endl; // modification for debugging
        fvScalarMatrix p_rghEqn
          fvm::laplacian(rAUf, p_rgh) == fvc::div(phi) // here comes the error
        Info << "done p_rghEqn setup\n" << endl;  // modification for debugging

The pressure equation was never touched and a diff test reveals that the only changes between the original file in buoyantBoussinesqSimpleFoam and my version are the lines highlighted with "modification for debugging"

Does anybody know why and how the solver wants to look up rho?

Nikhilcfd April 13, 2012 17:47

Hello Roman,

I am no expert in OpenFOAM and have not worked with "buoyantBoussinesqSimpleFoam" before, but I came across this error "request for volScalarField rho from objectRegistry region0 failed" when I modified interFoam to incorporate a new BC for dynamic contact angle. I don't know which part of the code is calling 'rho', but I guess because of your modifications it is being called and you don't have rho in the objectregistry. If that is the case all you need to do is add rho as volScalarField in createFields.H file.

Since this is not a multi-phase flow rho is not a volScalarField, but it would be interesting to see if that will let your code overcome or figure out the source of this error. Hope this helps. Please let me know if this woks.


romant April 14, 2012 08:32

solution found

I found the solution. It has to do with the boundary condition for pressure. The pressure boundary condition buoyantPressure calls rho therefore the boundary condition has to be given with the correct call for rho as in


  type  buoyantPressure;
  rho  rhok;

I think this should be valid for most of the incompressible solvers with buoyancy, since they do not have a real rho, but only the modified rhok

All times are GMT -4. The time now is 19:58.