CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   dimensioned problem in potentialFoam (http://www.cfd-online.com/Forums/openfoam-programming-development/110778-dimensioned-problem-potentialfoam.html)

T.Matrix December 20, 2012 10:31

dimensioned problem in potentialFoam
 
there is a define of pressure p as follow in the createFields.H in the potentialFoam:

volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
mesh
);

p = dimensionedScalar("zero", p.dimensions(), 0.0);

In my opinion, the pressure p is created with dimensionedless at first, and then assign its dimension according to dimensionedScalar("zero", p.dimensions(), 0.0). However, when p.dimensions() is called, the dimension of p in left is still dimensionless. Therefore, the dimension of p is not given.

At the same time, the same problem is also exist in the velocity U.

Lieven December 20, 2012 15:36

Hey T.Matrix,

The dimensions of p and U should be read from the input files. So if p.dimensions() is dimensionless, you should check the dimension set specified in 0/p and 0/U of the case.

Kind regards,

L

T.Matrix December 21, 2012 21:23

Hi Lieven,

the dimensions of p and U is given in the input files as normal, and potentialFoam can run correctly. However, the problem is how the dimensions is assigned in the source code. As far as I am concerned, volscalarField p is created by calling construction function GeometricField(*,*,*). In the following code, dimensions is not given to the construction GeometricField. Therefore, pressure p is created using the default dimension which is set dimensionless in the construction. So, in my opinion, p is created with no dimension. In fact, when source code is executed, p has its own dimension. I can't understand it.
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
mesh
);

Lieven December 22, 2012 05:16

Dear T.Matrix,

Quote:

So, in my opinion, p is created with no dimension..
The dimensions are not given explicitly in the source code but they are effectively read from the input file because IOobject::MUST_READ is set. This give the user the flexibility to chose them himself. Only when IOobject::MUST_READ would be IOobject::NO_READ or IOobject::READ_IF_PRESENT on the other hand, they would need to be provided in the source code.

If you add
Code:

Info << p.dimensions() << endl;
just before
Code:

p = dimensionedScalar("zero", p.dimensions(), 0.0);
you can verify yourself that the dimensions are taken from the input file (simply change them a few times)

The only reason
Code:

p = dimensionedScalar("zero", p.dimensions(), 0.0);
is added to the createFields.H is to reset the pressure field to 0.

Kind regards,

L

T.Matrix December 22, 2012 06:48

Hello L,

If Oobject::MUST_READ is set, the dimension is read from input file. However, the dimension is saved in a temporary IOobject. I just do not know how this temporary IOobject transport its dimension to dimension in volScalarField. I read relative codes several days but have no idea.

Matrix.T


All times are GMT -4. The time now is 11:02.