Difference between 'internalField' and 'boundaryField'?
Dear OFoamers,
as a new user of OpenFoam, I've maybe a very simple question .. but the OF-tutorial doesn't give a satisfying answer to me and I become more and more confused (as I tried to make some 'try and error calculations'). What does 'internalField' in e.g. a U-file describe ? And what is the difference between the 'internalField' and the 'boundaryField' (in detail) ? Thanks in advance, felix |
consider pressure (p), it is defined as volScalarField
means it defines in center of each cell in domain. domain has two parts : domain content (internalField) and domain surrounding (boundaryField). p.boundaryField() give you access to value in boundary, value in boundary would be surface center value. its helpful when you need the maximum, min, sum or average the value of a patch, so it returns a surfaceScalarField. p.internalField() returns a scalarField (im not sure, check it ;) ) , so it can be useful when you want to deal with internal value and keep boundary conditions unchanged. |
Hi felix,
I'm quite new to OpenFoam myself, but I can give a shot at explaining the internalField condition. For the velocity, U, the internalField characteristic is used to determine the properties of the fluid inside the computational domain. e.g. if the fluid is stationary and there is no velocity in any direction, the value will be uniform (0 0 0), whereas if we are addressing kinetic energy (scalar) and the initial conditions suggest there is some present, the value will be uniform x. In short, as far as I know, (and hopefully right), this condition is simply used to assign the appropriate initial properties to the fluid not located at any of the boundaries. Hope this helps. Dom. |
beside if you just asking about U file in directory 0;
consider you are going to solve a differential equation you need to have boundary condition and initial condition, internalField defines initial condition it can be uniform or nonuniform and boundaryField defines boundary condtion which is mathematical boundary condition likes : fixed value ( means value in that patch is defined ) or zeroGradient ( gradient of the variable in that boundary is zero) look more in user guide ;) |
Hi Nima, hi Dominic,
thanks for your fast replies ! These are exactly my missing information.. Nima: At the moment I'm only looking at some old cases to get known with all the different possibilities for all the settings.. but be sure, that I'll also read further in the user guide ! ;) kind regards, felix |
Quote:
Thanks for your clear description. Could you please add also that what is the difference between dimensionedInternalField() and InternalField()? I have the following equations. but when I am replacing the dimensionedInternalField() with InternalField() it gives the error. ( and there is no dimensionedboundaryField() ). A.dimensionedInternalField()=min(scalar(0),B.dimen sionedInternalField()); A.boundaryField()=min(scalar(0),B.boundaryField()) ; Best Mahdi |
you know variable has dimension, for example velocity dimension is {m/s}
OpenFOAM saves both variable values and its dimension, so dimensionedInternalField() has besides value of InternalField(), its dimension too! the error returns that you are going to compare a dimensionedvarible with a scalar, it is not allowed, you should define your zero! as a dimensionedScalar with appropriate dimension |
Quote:
But i was meaning that this formula is ok! Code:
Code:
|
and whats the error?
post the error here |
I know this is an old thread but I have a question related to this subject...
I'm trying to write a forAll loop and I keep on getting errors no matter how I code it. I tried coding it this way: Code:
forAll(f1,celli) Code:
error: cannot convert ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘double’ in assignment I understand that f1 is dimensionless, so I have also tried to use .value() instead of [celli] on xn and utau but when I do so, I get the following error: Code:
SPLRRIP.C: In member function ‘virtual void Foam::incompressible::RASModels::SPLRRIP::correct()’: Here is how I have defined utau, f1 and xn. Code:
xn |
You are dividing by nu(). What is nu()? Is it a field? If so, then you need to access also for nu() the cell values.
In general it's a good idea to get a reference to the internal/boundary fields and loop through these ones. Something like this: Code:
scalarField& f1Cells = f1.internalField(); |
Hello Armin,
I thought nu was the kinematic viscosity defined in constant > transportProperties. Since I'm running incompressible simulations, I assumed that nu() was just a constant value, which is why I wasn't trying to access the individual cell values. However, I tried indexing nu(): Code:
scalarField& f1Cells = f1.internalField(); Code:
SPLRRIP.C:459:58: error: invalid types ‘<unresolved overloaded function type>[Foam::label {aka int}]’ for array subscript Code:
forAll(f1Cells,celli) Code:
SPLRRIP.C:459:60: error: no match for ‘operator[]’ in ‘Foam::incompressible::turbulenceModel::nu() const()[celli]’ |
Quote:
No idea, what goes wrong in your code. Are you sure the error is related to the code you posted initially? Maybe you recheck the line numbers in the error message and source code. |
Thanks anyway Armin!
I know that the error is caused by the way that I am assigning the value to f1. OpenFOAM doesn't like the f1[celli]=exp(...) The reason (as far as I understand it) is that f1 is a field, but exp(...) returns a double. So, I'm trying to assign a 'double' to a cell within a field. I think I may have figured out a solution to the initial problem... now I have another one :( Coding it in the following way compiles (I know I should create a label but I'm testing for now): Code:
forAll(f1,celli) Code:
Starting time loop |
Quote:
f1 may be a field, but you can very well assign 'double' values to a cell. In fact when you do Code:
f1Cells[cellI] = 3.141592; Well, the solution for you is to bisect your code. Meaning, start with assigning 'double' values (e.g. 3.141592) to your cells and see if it compiles. If that works, add step by step more functions and see where it starts to go wrong. Good luck! :) |
Quote:
Where is that code anyways? In a solver or a library? Maybe you try to switch back to my initial example with the reference to the internal field and remove the nu(). Does that compile? |
Armin,
The code is part of a turbulence model (LRR). I tried doing Code:
f1Cells[cellI]=3.141564 I removed nu() and substituted it with it's numerical value and it compiled and ran! So the whole problem was being caused by nu(). How would you access the value of nu so that the loop will adopt the numerical value for the current simulation? The reason why I am confused is that I am able to access nu whenever it is outside of a loop. For example, if I have Code:
f1=exp(-0.5*xn*utau/nu()); The problem arises when nu() is used in the loop... |
Quote:
Quote:
|
That is a great question... After looking in transportModels/incompressible/viscosityModels/Newtonian I have learned that nu() is in fact a tmp field:
Code:
// Member Functions I don't understand why nu() can be accessed in a non-loop way but not from within a loop. Thank you so much for taking the time to work through this with me. |
Quote:
http://openfoamwiki.net/index.php/OpenFOAM_guide/tmp http://www.cfd-online.com/Forums/ope...acro-pain.html A fix to your problem would be something like this: Code:
const scalarField& nuCells = nu()().internalField(); Code:
f1Cells[cellI] = 3.141564*nuCells[cellI]; |
Thank you very much Armin! You solved my problem! :)
|
Accessing nu and nut vales
Hi there,
I am currently running a flow over backward facing step (using LES) in OpenFAOM 2.4.0. I want access to the kinematic viscosity. So in a ".H" file which I include in pisoFoam.C, I write the following just to see if I have access to nu (kinematic viscosity) value: Code:
I also want to access the nut values calculated by openFoam. Is there a function to access it ? Thanks in advance. |
All times are GMT -4. The time now is 20:24. |