CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   how to use the 'calculated' boundary condition (https://www.cfd-online.com/Forums/openfoam/102814-how-use-calculated-boundary-condition.html)

lg88 June 3, 2012 09:56

how to use the 'calculated' boundary condition
 
hello everyone
I want to solve a pressure Poisson equation with boundary conditions of value calculated on the last step. the P input file I set is as follow:


dimensions [0 2 -2 0 0 0 0];

internalField uniform 0;

boundaryField
{
IN
{
type zeroGradient;
}

OUT
{
type zeroGradient;
}

SIDE
{
type calculated;
}

}

But I get the following error:

FOAM FATAL ERROR:

gradientInternalCoeffs cannot be called for a calculatedFvPatchField on patch outflow of field p in file "/home/lg88/mfmFoam/0/p"
You are probably trying to solve for a field with a default boundary condition.

From function calculatedFvPatchField<Type>::gradientInternalCoef fs() const in file /opt/openfoam210/src/finiteVolume/lnInclude/calculatedFvPatchField.C at line 187.

Does anybody know how to use this boundary condition? where can i find similar tutorials?

Thank you very much!

lg88

gschaider June 3, 2012 10:59

Quote:

Originally Posted by lg88 (Post 364506)
But I get the following error:

FOAM FATAL ERROR:

gradientInternalCoeffs cannot be called for a calculatedFvPatchField on patch outflow of field p in file "/home/lg88/mfmFoam/0/p"
You are probably trying to solve for a field with a default boundary condition.

From function calculatedFvPatchField<Type>::gradientInternalCoef fs() const in file /opt/openfoam210/src/finiteVolume/lnInclude/calculatedFvPatchField.C at line 187.

Does anybody know how to use this boundary condition? where can i find similar tutorials?

You can't "use" the calculated-BC. It is only a placeholder when for instance you add two fields like "p1+p2" and is OFs way of saying "I don't know what this means for the boundary condition on this patch that p1 had fixedValue and p2 zeroGradient".
So calculated only makes sense in fields that OF wrote but not as a specification for a physical BC (that's why its in no tutorial)

lg88 June 4, 2012 03:21

Hi
But in the user-guide, the description of type 'calculated' is 'boundary condition phi derived from other fields'.
now I want to set Dirichlet boundary condition for P,but the boundary value will changes with the time.I need to use the last step value of field P1 as the next timestep boundary value of P.So I feel the type 'calculated' is my best choice.But it always occur the error I said above.

Does anyone can give me some suggestions?

Thank you very much!

lg88

gschaider June 4, 2012 18:30

Quote:

Originally Posted by lg88 (Post 364573)
Hi
But in the user-guide, the description of type 'calculated' is 'boundary condition phi derived from other fields'.

The UserGuide is right and I'm right. Sorry. "derived from other fields" means "result of a calculation (for instance) of fields". Which is what I explained above

If you don't believe me have a look at the source of the calculated-BC. THere is hardly any calculation going on. "calculated" stands for "has been calculated" not "will be calculated"

Quote:

Originally Posted by lg88 (Post 364573)
now I want to set Dirichlet boundary condition for P,but the boundary value will changes with the time.I need to use the last step value of field P1 as the next timestep boundary value of P.So I feel the type 'calculated' is my best choice.But it always occur the error I said above.

Does anyone can give me some suggestions?

Boundary conditions timeVaryingUniform, coded or groovyBC (you'll find information on them either in the UserGuide, this Forum or the Wiki). Depends on how complicated your time-dependence is.

lg88 June 4, 2012 22:42

Hi
Thank you for your quick reply!Now I know that 'calculated' is not my need.I saw a thread here:http://www.cfd-online.com/Forums/ope...step-ones.html
Mybe It is what I want to express.
What I really want to do is using the old time step value of P at SIDE to construct a "new" P for the new time step at the same patch.
So I think function oldTime() is my need? but I don'k know what kind of boundary condition should I use? And I am not sure whether OpenFOAM-1.6-ext contain the function?

Thank you very much

lg88

lg88 June 5, 2012 03:00

Hi
When I set my P input file as:
--------------------------------------------------------------------------
dimensions [0 2 -2 0 0 0 0];

internalField uniform 0;

boundaryField
{
IN
{
type zeroGradient;
}

OUT
{
type zeroGradient;
}

SIDE
{
type groovyBC;
valueExpressions "P@SIDE=oldTime(P@SIDE)";
value uniform 0;
}

}
I get the following error:

FOAM FATAL ERROR:
gradientInternalCoeffs cannot be called for a genericFvPatchField (actual type groovyBC)
on patch UB of field P in file "/home/lg88/FAM_FVMtutorials/0/P"
You are probably trying to solve for a field with a generic boundary condition.

From function genericFvPatchField<Type>::gradientInternalCoeffs( ) const
in file fields/fvPatchFields/basic/generic/genericFvPatchField.C at line 782.

Do you know what it means?

waiting for you reply! Thank you very much!

lg88

gschaider June 5, 2012 17:16

Quote:

Originally Posted by lg88 (Post 364748)
Hi
When I set my P input file as:
--------------------------------------------------------------------------
dimensions [0 2 -2 0 0 0 0];

internalField uniform 0;

boundaryField
{
IN
{
type zeroGradient;
}

OUT
{
type zeroGradient;
}

SIDE
{
type groovyBC;
valueExpressions "P@SIDE=oldTime(P@SIDE)";
value uniform 0;
}

}
I get the following error:

FOAM FATAL ERROR:
gradientInternalCoeffs cannot be called for a genericFvPatchField (actual type groovyBC)
on patch UB of field P in file "/home/lg88/FAM_FVMtutorials/0/P"
You are probably trying to solve for a field with a generic boundary condition.

From function genericFvPatchField<Type>::gradientInternalCoeffs( ) const
in file fields/fvPatchFields/basic/generic/genericFvPatchField.C at line 782.

Do you know what it means?

Basically that you didn't load the groovyBC-lib with the libs-entry in the controlDict and the solver therefor doesn't know about groovyBC. Read the docu. It is explained there

Concerning your boundary condition:
- oldTime is in my opinion unnecessary
- your value-expression won't work. You're mixing the valueExpression and variables here
- the notation of the remote variables is "old school". The one in swak is different

Quote:

Originally Posted by lg88 (Post 364748)
waiting for you reply!

Your time is better spent by reading the docu (there isn't much anyway) and looking at the examples

lg88 June 6, 2012 00:50

Hello
I have loaded and compiled the groovyBC-lib successfully.Then add
libs ( "libgroovyBC.so" ) ;
to the system/controlDict of my case.And it run fluently without errors I mentioned above.But I didn't get my expected result.So I think I haven't set the right boundary condition.
What I really want to do is using the old time step value of P at SIDE as a "new" P boundary value at the same patch for the new time step to solve P.Can you tell me what kind of boundary condition should I use ?And if groovyBC is right for me ,could you tell me how to write it?I have spend time reading the examples in groovyBC,but I can't come up with any ideas.


Thank you in advance!

lg88

gschaider June 6, 2012 14:58

Quote:

Originally Posted by lg88 (Post 364938)
Hello
I have loaded and compiled the groovyBC-lib successfully.Then add
libs ( "libgroovyBC.so" ) ;
to the system/controlDict of my case.And it run fluently without errors I mentioned above.But I didn't get my expected result.So I think I haven't set the right boundary condition.
What I really want to do is using the old time step value of P at SIDE as a "new" P boundary value at the same patch for the new time step to solve P.Can you tell me what kind of boundary condition should I use ?And if groovyBC is right for me ,could you tell me how to write it?I have spend time reading the examples in groovyBC,but I can't come up with any ideas.

What is the physical reason for such a boundary condition? "value at the last timestep" depends on your time-step and is therefore an artefact of the simulation. Your boundary condition would therefor only make sense in some strange universe where the time-step of your simulation is a physical constant of some kind

IF the solver stores the old time values then oldTime(p) gives you the previous value of p. If p hasn't been solved for yet during that time-step then p and oldTime(p) are the same. So if your valueExpression says "p" it should have the same meaning.
Anyway. Only application for oldTime(p) I see is if you want to get some kind of (under)relaxation.

Ahmed Khattab February 3, 2013 04:28

chtMultiRegionFoam
 
Quote:

Originally Posted by gschaider (Post 364720)
The UserGuide is right and I'm right. Sorry. "derived from other fields" means "result of a calculation (for instance) of fields". Which is what I explained above

If you don't believe me have a look at the source of the calculated-BC. THere is hardly any calculation going on. "calculated" stands for "has been calculated" not "will be calculated"



Boundary conditions timeVaryingUniform, coded or groovyBC (you'll find information on them either in the UserGuide, this Forum or the Wiki). Depends on how complicated your time-dependence is.

Hi,

i have a question about this calculated boundary condition. in chtMultiRegionFoam case p_rgh is specified as buoyant pressure and p as calculated. i want to know how p_rgh is calculated by user, and how p is calculated by processor, if p_rgh is dynamic pressure why it is specified although velocity is input.

thanks in advance,
Ahmed

nanduzz February 26, 2017 01:08

plz help
 
--> FOAM FATAL ERROR:

gradientInternalCoeffs cannot be called for a calculatedFvPatchField
on patch floor of field p in file "/home/nanduzz/OpenFOAM/nanduzz-3.0.1/run/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/0/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 199.

FOAM exiting
dimensions [0 2 -2 0 0 0 0];

internalField uniform 0;

boundaryField
{
floor
{
type calculated;
value $internalField;
}

ceiling
{
type calculated;
value $internalField;
}

fixedWalls
{
type calculated;
value $internalField;
}
}

guanjiang.chen May 9, 2022 10:47

Hi,

It seems that Calculated boundary could only be applied in the patch field, usually inlet and outlet. Is this right?

Regards,
Guanjiang


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