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

Error: gradientInternalCoeffs cannot be called for a calculatedFvPatchField

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 10, 2020, 04:18
Question Error: gradientInternalCoeffs cannot be called for a calculatedFvPatchField
  #1
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 348
Rep Power: 11
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Hello Foamers,
In my work, I'm calculating pressure through the following equation,
Quote:
del2(p2) = -(f1+f2*(rho*V)) * del.(rho*V) - (rho*V) . del(f1+f2*(rho*V))
My code gets compiled successfully. But, while running case file, it came up with the error,
Quote:
--> FOAM FATAL ERROR:
gradientInternalCoeffs cannot be called for a calculatedFvPatchField
on patch hotSide of field sqr(p) in file "/home/kumaresh/OpenFOAM/kumaresh-2.1.1/CASE_darcyFoam/@20200110_ErgunFoam/CASE2_2D_test_1hr/0/sqr(p)"
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 186.
I have checked few other threads related to this error. Most comments are related to problem with boundary conditions. I even tried adopting different strategics for this case. But it results in same error.
  • The problem is with "p2 = sqr(p)" as quoted in error.
  • Under createFields:
    Quote:
    volScalarField p
    (
    IOobject
    (
    "p",
    runTime.timeName(),
    mesh,
    IOobject::MUST_READ,
    IOobject::AUTO_WRITE
    ),
    mesh
    );
    Info<< "Reading field square of p\n" << endl;
    volScalarField p2(sqr(p));
  • Problem with defaultFvPatchField gradientInternalCoeffs - Here in the link, it was said that, "You are probably trying to solve for a field with a default boundary condition."
    This likely means that your boundary condition hasn't been linked in at all. So that my boundary condition has to be linked ?
**while solving the equation for only Pressure (p) variable without square term - the case gets compiled and runs good.

Anyone have some ideas as how to resolve the above error and proceed further.
Thank you
Kummi is offline   Reply With Quote

Old   January 10, 2020, 09:21
Default
  #2
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 348
Rep Power: 11
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
I checked few threads again..
Unexplained Error - Based on the explanation in this thread, I add a new read constructor for p2 in createFields.H as,
Quote:
volScalarField p2
(
IOobject
(
"p2",
runTime.timeName(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
//IOobject::NO_READ,
IOobject::AUTO_WRITE
),
//mesh
sqr(p)
//dimensionedScalar("p2", dimensionSet(2,-2,-4,0,0,0,0),0)
);
and defined p2 inside 0 boundary condition as,
Quote:
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object p2;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [ 2 -2 -4 0 0 0 0 ];
internalField uniform 101325;
boundaryField
{
hotSide
{
type calculated;
value $internalField;
}

right
{
type symmetryPlane;
}
top
{
type calculated;
value $internalField;
}

bottom
{
type zeroGradient;
}

front
{
type empty;
}

back
{
type empty;
}
Compilation - no problem
While running case file, there comes same error as:
Quote:
--> FOAM FATAL ERROR:

gradientInternalCoeffs cannot be called for a calculatedFvPatchField
on patch hotSide of field p2 in file "/home/kumaresh/OpenFOAM/kumaresh-2.1.1/CASE_darcyFoam/@20200110_ErgunFoam/CASE2_2D_test_1hr/0/p2"
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 186.

FOAM exiting
Kindly someone suggest me some ideas

Thank you
Kummi is offline   Reply With Quote

Old   January 10, 2020, 10:01
Default
  #3
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 348
Rep Power: 11
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
I feel there is problem with the declaration of code - in an implicit squared term.
Quote:
del2(p2) = -(f1+f2*(rho*V)) * del.(rho*V) - (rho*V) . del(f1+f2*(rho*V))
  • fvm::laplacian(p2) == - (2*T*R)*(((f1+(f2*rho*Ux))*RRg) + (rho*Uy*gradBigxx))
Such declaration is right ??
volScalarField p2(sqr(p)); //based on volScalarField p
Kummi is offline   Reply With Quote

Old   January 10, 2020, 10:57
Default
  #4
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 15
adhiraj is on a distinguished road
A couple of things I notice here, which may help.

1. You have a new variable p2 which you are defining as the square of p. Doing that may not set proper boundary conditions on p2. My guess is that the boundary conditions of p2 are being set to 'calculated', and thus you cannot solve an equation for p2.

2. You provide a constructor for p2 in another attempt, but the p2 file has 'calculated' boundaries.

Since p2 is the variable you intend to use in the formulation, you need to figure out what boundary conditions make sense for it. Then initialize p2 accordingly.

See if that helps.
adhiraj is offline   Reply With Quote

Old   January 10, 2020, 11:39
Default
  #5
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 348
Rep Power: 11
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Thank you for your response Adjiraj.
p2 (square of pressure) used in my formulation. There is no specific boundary condition for variable p2 because it is just square of pressure.
Then how to initialize p2 accordingly?
Correct me if Im wrong please
Kummi is offline   Reply With Quote

Old   January 10, 2020, 14:18
Default
  #6
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 15
adhiraj is on a distinguished road
Quote:
Originally Posted by Kummi View Post
p2 (square of pressure) used in my formulation. There is no specific boundary condition for variable p2 because it is just square of pressure.
If you are solving an equation for any variable, you will almost always need to prescribe boundary conditions for it. In this case you will need to derive the boundary conditions from the corresponding boundary for p.

Quote:
Originally Posted by Kummi View Post
Then how to initialize p2 accordingly?
Once again, determine the appropriate initial conditions and boundary conditions from those of p.

Hope this helps.
adhiraj is offline   Reply With Quote

Old   January 11, 2020, 02:18
Default
  #7
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 348
Rep Power: 11
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Dear Adhiraj,
Thank you for your comments.
As per your point, in order to solve the variable p2 in the equation, I should prescribe the appropriate initial and boundary condition for p2 based on the corresponding boundary p.
Quote:
In this case you will need to derive the boundary conditions from the corresponding boundary for p.
As you mentioned, I should derive the boundary condition ?? Could you please elaborate your explanation? and if possible can you please highlight any such problems before.. Because I don't find such cases.
For pressure p, I have defined reasonable boundary conditions (below)
Quote:
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object p;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [ 1 -1 -2 0 0 0 0 ];
internalField uniform 101325;
boundaryField
{
hotSide
{
type fixedValue;
value $internalField;
}

right
{
type symmetryPlane;
}

top
{
type fixedValue;
value $internalField;
}

bottom
{
type zeroGradient;
}

front
{
type empty;
}

back
{
type empty;
}
Kummi is offline   Reply With Quote

Old   January 11, 2020, 06:36
Default
  #8
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 348
Rep Power: 11
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
In comment 2 of this thread, p2 is fitted with *calculated* boundary condition. I dont find anyother appropriate boundary condition will fit for p2.
Kindly share some ideas. Thank you
Kummi is offline   Reply With Quote

Old   January 11, 2020, 12:36
Default
  #9
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 15
adhiraj is on a distinguished road
Yes, you need to derive the boundary conditions and initial conditions for a new variable.

For example, if at a particular boundary the boundary condition for p is 'fixedValue' with a value of 10, p2 at the boundary can be 'fixedValue', with a value of {10}^{2} = 100. Use the same process for other boundaries and the initial condition.

The 'calculated' boundary condition is not really a true boundary condition that solvers can use. It is simply a placeholder.
adhiraj is offline   Reply With Quote

Old   January 11, 2020, 22:40
Question Files attached !!
  #10
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 348
Rep Power: 11
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Dear Adhiraj,
Thank you for your comments.
As you mentioned, I defined p2 boundary with 'fixedValue'. It ends up with same error.
Quote:
--> FOAM FATAL ERROR:

gradientInternalCoeffs cannot be called for a calculatedFvPatchField
on patch hotSide of field p2 in file "/home/kumaresh/OpenFOAM/kumaresh-2.1.1/CASE_darcyFoam/@20200110_ErgunFoam/CASE2_2D_test_1hr/0/p2"
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 186.
For your verification, I'm attaching the solver and case files. Kindly check it in your leisure time please. Thank you once again.
Attached Files
File Type: gz @20200110_ErgunFoam.tar.gz (5.7 KB, 8 views)
Kummi is offline   Reply With Quote

Old   January 12, 2020, 18:19
Default
  #11
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 15
adhiraj is on a distinguished road
The error message seems to indicate that the code is still seeing p2 with 'calculated' boundary condition.

In your createFields.H file, why don't you initialize p2 like this?
Code:
Info<< "Reading field square of p\n" << endl;

volScalarField p2
(
    IOobject
    (
        "p2",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
    ),
    mesh
);
adhiraj is offline   Reply With Quote

Old   January 12, 2020, 23:39
Default
  #12
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 348
Rep Power: 11
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Dear Adhiraj,
Thank you very much. It worked. Then, I guess - no need to solve p. I will solve p2 directly by taking the squared value.
No more errors.
Kummi is offline   Reply With Quote

Old   January 12, 2020, 23:46
Question solving U and p
  #13
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 348
Rep Power: 11
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Dear Adhiraj,
Irrespective of this thread caption, I have one more question. In my work, I need to resolve two variables U and p.
As given in the attachment, I derived 2 equations for velocities to calculate Ux and Uy.
Followed by the pressure equation to solve pressure. Firstly, once after resolving velocities along x and y, pressure will be solved.

I defined the equations in OpenFOAM, gets compiled and the case runs without error. During post-processing, I dont find change in velocity inside my domain. However, the pressure (p2) variable is changed. Quite confused here. I guess my syntax is right.

I'm hereby attaching my code and case files.

If you are free, kindly check it please.
Thank you
Attached Images
File Type: png Equs..png (51.0 KB, 16 views)
File Type: png Velocity - no change.png (15.6 KB, 12 views)
File Type: png pressure.png (19.2 KB, 9 views)
Attached Files
File Type: gz ErgunFoam.tar.gz (110.7 KB, 7 views)
Kummi is offline   Reply With Quote

Old   January 13, 2020, 11:25
Default
  #14
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 15
adhiraj is on a distinguished road
Quote:
Originally Posted by Kummi View Post
Dear Adhiraj,
Thank you very much. It worked. Then, I guess - no need to solve p. I will solve p2 directly by taking the squared value.
No more errors.
It may be useful for your understanding of OpenFOAM if you can figure out why this approach works, while the other does not.

Quote:
Originally Posted by Kummi View Post
Irrespective of this thread caption, I have one more question.
Please create a new thread for the new question.
adhiraj is offline   Reply With Quote

Old   January 13, 2020, 21:09
Default
  #15
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 348
Rep Power: 11
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Quote:
Originally Posted by adhiraj View Post
It may be useful for your understanding of OpenFOAM if you can figure out why this approach works, while the other does not.
Please create a new thread for the new question.
Understood the reason behind the approach and got your valid points.
Thank you Adhiraj for your valuable time.
*I will post my new query as a new thread.
Kummi 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
Cloud::storeGlobalPositions has not been called - How to call it? mrishi OpenFOAM Programming & Development 16 January 28, 2021 19:46
How is the turbulence model called in openfoam? hz283 OpenFOAM 3 May 4, 2017 21:20
terminate called after throwing an instance of 'int' b614910 SU2 10 July 27, 2014 22:16
understanding how turbulence models are called romant OpenFOAM Programming & Development 0 March 21, 2012 09:22
reconstructParMesh not working with an axisymetric case francesco OpenFOAM Bugs 4 May 8, 2009 05:49


All times are GMT -4. The time now is 04:37.