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/)
-   -   gradientInternalCoeffs cannot be called for a calculatedFvPatchField (https://www.cfd-online.com/Forums/openfoam-programming-development/107479-gradientinternalcoeffs-cannot-called-calculatedfvpatchfield.html)

adambarfi September 28, 2012 05:27

gradientInternalCoeffs cannot be called for a calculatedFvPatchField
 
hi everybody,

I defined a new solver that solve natural convection in a viscoelastic Fluid. it made successfully, but when I want to run my model the following error was appeared:

Code:

--> FOAM FATAL ERROR:

    gradientInternalCoeffs cannot be called for a calculatedFvPatchField
    on patch floor of field p in file "/home/mostafa/OpenFOAM/mostafa-2.1.0/run/tutorials/viscoelastic/viscoelasticFluidFoam/Hasan_Giesekus/0/p"
    You are probably trying to solve for a field with a default boundary condition.
    From function calculatedFvPatchField<Type>::gradientInternalCoeffs() const
    in file fields/fvPatchFields/basic/calculated/calculatedFvPatchField.C at line 186.

  FOAM exiting

do anybody know where is the problem?

Thanks

nimasam September 28, 2012 15:01

DEAR mostafa
could you post your p file here?

adambarfi September 28, 2012 16:08

1 Attachment(s)
the attachment contains the p, fvSolution and fvSchemes files.
I changed the floor boundary condition and even delete the p file but this problem didn't had been solve. I think the problem is somewhere in the fvSolution or fvSchemes.

nimasam September 28, 2012 17:37

this solver reads p or p-rgh ?
it seems it reads p, if it reads p! then you should define BC for p, you can not use calculated BC, you should use (fixedValue or fixedGradient) for it :D

adambarfi September 28, 2012 23:36

Quote:

Originally Posted by nimasam (Post 384130)
this solver reads p or p-rgh ?
it seems it reads p, if it reads p! then you should define BC for p, you can not use calculated BC, you should use (fixedValue or fixedGradient) for it :D

It reads p and calculate the p-rgh, such as bouyantbuossinesqsimplefoam. I change the bc to fixedValue and fixedGradient but this this error didn't had been omit.

nimasam September 29, 2012 02:57

Dear mostafa let me ask another questions, which version of openfoam do you use?
could you run this test case before heat transfer implementation?
put the test case and solver here, then may other can help you

ata September 29, 2012 05:42

Hi
Did you set p equal to another field in your solver during calculations? i.g.
p=....?

adambarfi September 29, 2012 06:09

this is where I use the p in createFields.H:
Code:

    Info<< "Calculating field g.h\n" << endl;
    volScalarField gh("gh", g & mesh.C());
    surfaceScalarField ghf("ghf", g & mesh.Cf());

    volScalarField p
    (
        IOobject
        (
            "p",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        p_rgh + rhok*gh
    );

    label pRefCell = 0;
    scalar pRefValue = 0.0;
    setRefCell(p,p_rgh, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue);


    if (p_rgh.needReference())
    {
        p += dimensionedScalar
        (
            "p",
            p.dimensions(),
            pRefValue - getRefCellValue(p, pRefCell)
        );
    }

and in pEqn:

Code:

    p = p_rgh + rhok*gh;

    if (p_rgh.needReference())
    {
        p += dimensionedScalar
        (
            "p",
            p.dimensions(),
            pRefValue - getRefCellValue(p, pRefCell)
        );
        p_rgh = p - rhok*gh;
    }

what is wrong in my code?

ata September 29, 2012 06:33

Hi
I think you have two options two solve the problem. Selection is your choice:
1:
volScalarField p ( IOobject ( "p", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh );
or
2:
p == p_rgh + rhok*gh;

adambarfi September 29, 2012 07:21

Dear Ata
I applied what you offered me and what Nima said, that error was solved. but after some iterations (50) the following error appeared:
Code:

#0  Foam::error::printStack(Foam::Ostream&) in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"
#1  Foam::sigFpe::sigHandler(int) in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"
#2  Uninterpreted:
#3  Foam::PBiCG::solve(Foam::Field<double>&, Foam::Field<double> const&, unsigned char) const in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"
#4  Foam::fvMatrix<Foam::SymmTensor<double> >::solve(Foam::dictionary const&) in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linuxGccDPOpt/lib/libviscoelasticTransportModels.so"
#5  Foam::fvMatrix<Foam::SymmTensor<double> >::solve() in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linuxGccDPOpt/lib/libviscoelasticTransportModels.so"
#6  Foam::Giesekus::correct() in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linuxGccDPOpt/lib/libviscoelasticTransportModels.so"
#7  Foam::multiMode::correct() in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linuxGccDPOpt/lib/libviscoelasticTransportModels.so"
#8  Foam::viscoelasticModel::correct() in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linuxGccDPOpt/lib/libviscoelasticTransportModels.so"
#9 
 in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linuxGccDPOpt/bin/BuoyantBoussinesqViscoelasticFluidFoam"
#10  __libc_start_main in "/lib/i386-linux-gnu/libc.so.6"
#11 
 in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linuxGccDPOpt/bin/BuoyantBoussinesqViscoelasticFluidFoam"
Floating point exception

what is your opinion about this error?

again thank you so much

nimasam September 29, 2012 15:21

it seems somewhere in your code something divide on zero or going to result indefinite value

Tushar@cfd February 23, 2013 01:34

Dear adambarfi,
 
Are you able to resolve your error?

adambarfi February 23, 2013 01:44

Quote:

Originally Posted by Tushar@cfd (Post 409630)
Are you able to resolve your error?

Dear Tushar,
yes, after some day hard working, finally I could solve it.

Sasy November 11, 2013 02:06

2 Attachment(s)
Quote:

Originally Posted by adambarfi (Post 409631)
Dear Tushar,
yes, after some day hard working, finally I could solve it.

Dear Mostafa
how do you solved this problem?? I have some problem like this,but my problem dont solve by ata or nima offers...
I use interPhasechangeFoam solver and modified this solver for my simulation...
you can see my creatFields and Peqn

adambarfi November 12, 2013 00:46

hi Sasan,

I get your attached files and I couldn't find any thing that made error!

so, attach your log file + the errors expression

Sasy November 12, 2013 03:18

1 Attachment(s)
Quote:

Originally Posted by adambarfi (Post 461624)
hi Sasan,

I get your attached files and I couldn't find any thing that made error!

so, attach your log file + the errors expression

Hi Mostafa
Thank you for reply..
my error:
FOAM FATAL ERROR:

gradientInternalCoeffs cannot be called for a calculatedFvPatchField
on patch left of field p in file "/home/Sasan/Desktop/HardtMix/stephanProblem/0/p"
You are probably trying to solve for a field with a default boundary condition.
and attach the log file

adambarfi November 12, 2013 07:10

You have to specify correct boundary conditions for p otherwise you cannot solve the pEqn!

The error message gave you already a hint what you have to do:
Code:

on patch left of field p in file "/home/Sasan/Desktop/HardtMix/stephanProblem/0/p"
    You are probably trying to solve for a field with a default boundary condition.

so, you are using a wrong BC for pEqn. I guess you used calculated type!
try other boundary conditions that are compatible with your solution.

Sasy November 13, 2013 02:03

Quote:

Originally Posted by adambarfi (Post 461665)
You have to specify correct boundary conditions for p otherwise you cannot solve the pEqn!

The error message gave you already a hint what you have to do:
Code:

on patch left of field p in file "/home/Sasan/Desktop/HardtMix/stephanProblem/0/p"
    You are probably trying to solve for a field with a default boundary condition.

so, you are using a wrong BC for pEqn. I guess you used calculated type!
try other boundary conditions that are compatible with your solution.

Hi Mostafa
I used this test case with another solver and dont have problem,But for new solver,I have this problem.
my BC is not calculated....!!
you can see:

Sasy November 13, 2013 02:04

1 Attachment(s)
Quote:

Originally Posted by Sasy (Post 461759)
Hi Mostafa
I used this test case with another solver and dont have problem,But for new solver,I have this problem.
my BC is not calculated....!!
you can see:

sorry.I forgot attach my file...:p

adambarfi November 13, 2013 03:07

mhmm, I think there are problems with p BCs.
the userGuide says:

Quote:

At all wall boundaries, the buoyantPressure boundary condition is applied to the pressure
field, which calculates the normal gradient from the local density gradient.

buoyantPressure: Sets fixedGradient pressure based on the atmospheric pressure gradient

I think such same BCs for p and p_rgh is wrong, let the solver calculate the pressure based upon potential function. try "calculated" type for p BCs.

Also, I can't understand these conditions you used for p_rgh:
Code:

        type            buoyantPressure;
        gradient        uniform 0;
        value          uniform 0;

try this one:
Code:

        type            buoyantPressure;
        rho            rhok;
        value          uniform 0;

see the buoyantBoussinesqPimpleFoam and buoyantBoussinesqSimpleFoam solvers. they have tips that may help you.

Nazanin November 13, 2013 04:11

I send for you

Sasy November 13, 2013 04:28

Quote:

Originally Posted by adambarfi (Post 461770)
mhmm, I think there are problems with p BCs.
the userGuide says:

I think such same BCs for p and p_rgh is wrong, let the solver calculate the pressure based upon potential function. try "calculated" type for p BCs.

Also, I can't understand these conditions you used for p_rgh:
Code:

        type            buoyantPressure;
        gradient        uniform 0;
        value          uniform 0;

try this one:
Code:

        type            buoyantPressure;
        rho            rhok;
        value          uniform 0;

see the buoyantBoussinesqPimpleFoam and buoyantBoussinesqSimpleFoam solvers. they have tips that may help you.

Hi
I try this BCs,but the problem is still.
first I try this boundary condition:
type buoyantPressure;
value uniform 0;
and This
type zeroGradient;
but no answer...:confused:
NOTE:my case is 1D and I think should use this BCs
Regards,

lramutti March 27, 2014 15:59

Hey guys, I am ran into something similar for a conjugate heat transfer problem. In my case it says:

--> FOAM FATAL ERROR:

gradientInternalCoeffs cannot be called for a calculatedFvPatchField
on patch leftWall of field h in file "/home/meisu/OpenFOAM/meisu-2.2.1/run/Research/ConjugateHeatTransfer/RayleighBenard/caseFourDomeFourWalls/0/leftWall/h"
You are probably trying to solve for a field with a default boundary condition.

From function calculatedFvPatchField<Type>::gradientInternalCoef fs() const
in file fields/fvPatchFields/basic/calculated/calculatedFvPatchField.C at line 199.

The question I have is what h file is OpenFOAM referring to? I only don't have any h scripts.

Thanks!

lramutti March 27, 2014 17:48

Hey guys,

I solved the problem. I did not spell correctly the name of my boundary condition. It should have been labeled as leftWall instead of leftwall. Silly mistakes can consume a lot of time :D.

zhouzhipeng77 April 17, 2014 23:03

Hi Mostafa ,
I have some questions with the following code in createFields.H . ANd I look forward to your help .
1. regarding this code "p_rgh + rhok*gh" , rhok is calculated from temperature T , so it is different in different position , why can we use this formula for uniform rho ?
Quote:

volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
p_rgh + rhok*gh
);
2. about the setRefCell function , what is its function with p and a_rgh , or can you explain the process of this function ?
Quote:

label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell
(
p,
p_rgh,
mesh.solutionDict().subDict("PIMPLE"),
pRefCell,
pRefValue
);
3. with the following code , how dose it process ?
Quote:

if (p_rgh.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pRefValue - getRefCellValue(p, pRefCell)
);
}
Thanks
Zhipeng

adambarfi April 18, 2014 00:42

Hi Zhipeng and welcome

1-
remember the momentum equation and the Boussinesq approximation for naural convection:
\frac{\partial}{\partial t}\left( \rho u_i \right) +
\frac{\partial}{\partial x_j}
\left[ \rho u_i u_j + p \delta_{ij} - \tau_{ji} \right] = \rho g_{i}, \quad i=1,2,3

(\rho - \rho_{0}) g_{i} = -\rho_{0} g_{i} \beta (T-T_{0})

for the case of constant density and gravity, the term \rho g can be written as grad(\rho g . r), where r is the position vector. then -\rho g_{i} x{i} is the hydrostatic pressure, and it's convenient- and for numerical solution more efficient- to define \overline{p}=p - \rho g_{i} x_{i} as the head and use it in place of the pressure.
In variable density flows, one can split the \rho g_{i} term into two parts: \rho_{0} g_{i} +(\rho - \rho_{0}) g_{i}.

for more information you can refer to Ferziger's textbook (computational methods for fluid dynamics).

2-3
The solver needs to know what and where the reference pressure is. according to the explanation in 1 and below quote, I think you can get the answer of your questions.
Quote:

in OpenFOAM pRef is used only if your boundary conditions are set in such a way not to prescribe any reference for the pressure.

So, for example, if you open a duct open to the athmosphere at the outlet, and you have the velocity specified at the inlet, you should specify p equal to zero at the outlet (in incompressible flows, if you specify 1 it doesn't make any difference, you simply translate the values of the pressure in your whole domain of the same difference).

If you have a simulation where p has only Neumann (zeroGradient) conditions, the pRef value will be used, setting p = pRefVal in the cell of index pRefCell.

The values of pRefCell and pRefValue are always specified in the PISO/SIMPLE/PIMPLE subdictionary in fvSolution.
to find out how the pEqn.H works you can see the below link:
http://foam.sourceforge.net/docs/cpp/a02937.html

Bests,
Mostafa

zhouzhipeng77 April 20, 2014 22:58

Hi , Mostafa ,
Thank you for your help , and I have understand the question , but I can understand the following code in pEqn.H , though I have read the link you telll me .
Quote:

{
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())
+ fvc::ddtPhiCorr(rAU, U, phi);

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

while (pimple.correctNonOrthogonal())
{
fvScalarMatrix p_rghEqn
(
fvm::laplacian(rAUf, p_rgh) == fvc::div(phi)
);

p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));

p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.fin alInnerIter())));

if (pimple.finalNonOrthogonalIter())
{
// Calculate the conservative fluxes
phi -= p_rghEqn.flux();

// Explicitly relax pressure for momentum corrector
p_rgh.relax();

// Correct the momentum source with the pressure gradient flux
// calculated from the relaxed pressure
U -= rAU*fvc::reconstruct((buoyancyPhi + p_rghEqn.flux())/rAUf);
U.correctBoundaryConditions();
}
}
Can anybody help me to explain this , or introduce me some papers I should read ?
Thanks
Zhipeng

adambarfi April 20, 2014 23:50

the explanation of this algorithm here for me is not very easy!! so I attach you a note about the SIMPLE algorithm for pressure-velocity coupling and 4 links about the PISO and SIMPLE algorithm and the implementation of them with OF:

https://www.dropbox.com/s/lplecnozku...MPLEslides.pdf

The_SIMPLE_algorithm_in_OpenFOAM

The_PISO_algorithm_in_OpenFOAM

BuoyantBoussinesqPisoFoam

SIMPLE_algorithm

hope they can help you

Lisandro Maders July 29, 2015 21:18

same error for [b]h[/b] file.. but I don't have such file in my [b]0[/b] folder
 
Hello,

I have the same error posted before:

Code:

--> FOAM FATAL ERROR:

    gradientInternalCoeffs cannot be called for a calculatedFvPatchField
    on patch OUTLET of field h in file "/home/lisandro/OpenFOAM/lisandro-2.3.0/run/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/0/h"
    You are probably trying to solve for a field with a default boundary condition.

    From function calculatedFvPatchField<Type>::gradientInternalCoeffs() const
    in file fields/fvPatchFields/basic/calculated/calculatedFvPatchField.C at line 199.

FOAM exiting

The thing is, I don't have this file in my 0 folder, I have the T file instead as well as species files. I am running the counterFlowFlame2D tutorial but I changed the mesh..

Why is it looking for the h file?



Best,

Lisandro

Lisandro Maders September 11, 2015 09:31

Just as a matter of fact, I solved the issue above by changing the BC type of N2 (inert specie) in the Outlet patch. It was calculated and I put zeroGradient and I got no errors anymore.

Lisandro


All times are GMT -4. The time now is 03:21.