CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Create GeometricField without IOobject (http://www.cfd-online.com/Forums/openfoam-solving/58646-create-geometricfield-without-ioobject.html)

nadine August 14, 2008 10:23

Hello, sounds trivial, but ho
 
Hello,
sounds trivial, but how do I create a volScalarField, if I have a Field<double> and a volMesh?

Here mesh.Sf() and U are two volVectorFields from which the operator& calculates the inner product, a scalar field:
Field<double> Phi=mesh.Sf() & U;

But later I need a volScalarField with the values of Phi, and I see no possibility to construct this volScalarField although all geometric information is available.

The problem is that every GeometricField<...> constructor requires an IOobject, and every IOobject constructor requires a filename, so that GeometricFields can never be generated on the fly (unless copied from another GeometricField), but must always be read from a file.

Is this true?

N. Blanc

nadine August 14, 2008 15:18

correction: 1) "Here mesh.
 
correction:

1)
"Here mesh.Sf() and U are two volVectorFields..."
should read
"Here mesh.Sf() and U are a surfaceScalarField and a volVectorField..."

2)
"But later I need a volScalarField with the values of Phi, and I see no possibility to construct this volScalarField..."
should read
"But later I need a surfaceScalarField with the values of Phi, and I see no possibility to construct this surfaceScalarField..."

Still the question is:
How can I create a GeometricField from a Field and a Mesh without reading from an IOobject/file?

Best,
N. Blanc

eugene August 15, 2008 07:13

GeometricField.H has all the c
 
GeometricField.H has all the constructors. There are many. For an example on how to create a field without reading, check this file:

src/finiteVolume/lnInclude/createPhi.H

To reconstruct a face field:

fvc::reconstruct(phi);

or

fvc::average(phi);

Depending on what you want to achieve.

nadine August 15, 2008 09:24

Thank you, Eugene! My mistake
 
Thank you, Eugene!
My mistake was that I thought an IOobject is always initialized from a file. The example createPhi.H made things clearer.

NB


All times are GMT -4. The time now is 05:55.