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/)
-   -   Difference between internalField and setFields (http://www.cfd-online.com/Forums/openfoam-solving/111568-difference-between-internalfield-setfields.html)

haze_1986 January 10, 2013 03:19

Difference between internalField and setFields
 
Hi all, I am new here. Following the guide on shallowWaterFoam, I am not sure why at the start we have included the internalFields, which I assume is the initial conditions, and we still have to run setFields before running foam? Can anyone enlighten me?

ata January 14, 2013 02:59

Hi
internalFields are your fields like pressure field velocity field and etc. setFields is a function that initialize your requested fields.

haze_1986 January 14, 2013 03:24

Hi, could you please elaborate further with examples? I.e. for the shallowwaterfoam, if we did not use setfields, wouldn't it be the same as it would take the field values initially?

GerhardHolzinger January 15, 2013 08:24

When you want to define an internal field with internalField you have two options:

Either define a uniform value for the whole domain, or use a list to assign each cell its own value.


setFields is a utility which you can use to define geometric regions with different field values.


Example: You want to initialize a half empty water glass.

The two-phase solvers use a scalar field - the volume fraction alpha1 - to quantify how much water/air a cell contains. In the case of the water glass alpha1=0 means only water and alpha1=1 means only air.

This is a setFieldsDict entry to initialize a partly filled vessel.

Code:

defaultFieldValues
(
    volScalarFieldValue alpha1 1
);

// alpha1 = 0  <=>  no air, only water
regions
(
    // Set cell values
    // (does zerogradient on boundaries)
    boxToCell
    {
        box (-0.3 -0.3 0) (0.3 0.3 0.39);

        fieldValues
        (
            volScalarFieldValue alpha1 0
        );
    }
);

In the case of a non-uniform internal field, you can also use the internalField keyword. However, this gets lengthy - see the bubble column tutorial of the twoPhaseEulerFoam solver


The following is a part of the 0/alpha1 file of the bubble column tutorial of twoPhaseEulerFoam. There the internal field is defined using the internalField keyword. In this case you have 1875 cells. Consequently, the list has to be 1875 entries long.

Code:

internalField  nonuniform List<scalar>
1875
(
0.0548304
0.0623421
// and so on ....


haze_1986 January 15, 2013 08:39

Quote:

Originally Posted by GerhardHolzinger (Post 401935)
When you want to define an internal field with internalField you have two options:

Either define a uniform value for the whole domain, or use a list to assign each cell its own value.


setFields is a utility which you can use to define geometric regions with different field values.


Example: You want to initialize a half empty water glass.

The two-phase solvers use a scalar field - the volume fraction alpha1 - to quantify how much water/air a cell contains. In the case of the water glass alpha1=0 means only water and alpha1=1 means only air.

This is a setFieldsDict entry to initialize a partly filled vessel.

Code:

defaultFieldValues
(
    volScalarFieldValue alpha1 1
);

// alpha1 = 0  <=>  no air, only water
regions
(
    // Set cell values
    // (does zerogradient on boundaries)
    boxToCell
    {
        box (-0.3 -0.3 0) (0.3 0.3 0.39);

        fieldValues
        (
            volScalarFieldValue alpha1 0
        );
    }
);

In the case of a non-uniform internal field, you can also use the internalField keyword. However, this gets lengthy - see the bubble column tutorial of the twoPhaseEulerFoam solver


The following is a part of the 0/alpha1 file of the bubble column tutorial of twoPhaseEulerFoam. There the internal field is defined using the internalField keyword. In this case you have 1875 cells. Consequently, the list has to be 1875 entries long.

Code:

internalField  nonuniform List<scalar>
1875
(
0.0548304
0.0623421
// and so on ....


Hi GerhardHolzinger,

Thanks for the explanation, thus am I right to say that in the shalloWaterFoam example the results will be the same even if setFields isn't used? Since it has been described in internalfield in each cell at the start? No alpha1 is used there.

Sherlock_1812 September 21, 2013 09:12

setFields to set non uniform list for internal Field?
 
Hi,

can I use setFields to set a non uniform Temperature field like T = Ax+By in the internal Field in a simple geometry like a cavity? If yes, what should the setFieldsDict contain?

Thank you in advance!

ahmmedshakil September 21, 2013 11:02

Quote:

Originally Posted by Sherlock_1812 (Post 452870)
Hi,

can I use setFields to set a non uniform Temperature field like T = Ax+By in the internal Field in a simple geometry like a cavity? If yes, what should the setFieldsDict contain?

Thank you in advance!

Hi,
You can use funkySetFields that comes with swak4Foam.

banji January 13, 2014 22:02

Hi Ata,

Did you see my message concerning interFoam with smoother. Thanks.


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