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/)
-   -   ???Weird value of gamma field I got in my BC file! (http://www.cfd-online.com/Forums/openfoam-programming-development/70801-weird-value-gamma-field-i-got-my-bc-file.html)

zhajingjing December 6, 2009 21:54

???Weird value of gamma field I got in my BC file!
 
I'm coding a new boundary condition to be used in interFoam solver to solver free-surface problem.

I have to make use of the transient gamma value in my boundary condition.So I add the following to my boundary condition file:

Code:

void waveMakerVelocityOFvPatchVectorField::updateCoeffs() 
{
  ....
          const fvMesh& mesh = this->dimensionedInternalField().mesh();

          const fvPatchScalarField& gamma =
                      this->patch().lookupPatchField<volScalarField,scalar >("gamma"); 

        scalar cellLabel(0);
 
        for(int i=0;i < 60;i++)
        {
                    scalar y=-0.6+0.6/30/2+0.6/30/2*i;  //fetch the gamma value at the cells at the boundary
                   
                    point cellProbe(0,y,0.005);
                     
                    cellLabel=mesh.findCell(cellProbe);//
 
                    if(cellLabel==-1) 
                    { 
                      FatalError<<"select x again please"
                      << nl << exit(FatalError);
                    }
                    else
                    {
                      Info<<i<<"      "<<gamma[cellLabel]<<endl;  // write the gamma value
                    }
          }   

      .....

}

The gamma field value at the inlet boundary seem quite weird:

You see:
....
Create mesh for time = 0
........
(the output gamma values at the inlet boundary cells)
0 1
1 1
2 1
3 1
4 1
5 100
6 100
7 100

8 1.196806e-311
9 1.196806e-311
10 1.273197e-313
11 1.273197e-313
12 100
13 0.002
14 0.002
15 0.002
16 0.002
17 0.002
18 0.002
19 1.304015e-259
20 1.304015e-259
21 1.304015e-259
22 5.24133e-312
23 5.24133e-312
24 0
25 0
26 0
27 0
28 0
29 0
30 2.631275e-311
31 3.692273e-311
32 3.692273e-311
33 4.751149e-311
34 4.751149e-311
35 5.812146e-311
36 5.812146e-311
37 1
38 1
39 0
40 0
41 0
42 0
43 0
44 0
45 0
46 0
47 1.273197e-313
48 1.273197e-313
49 1.273197e-313
50 1.273197e-313
51 1.273197e-313
52 1.273197e-313
53 1.273197e-313
54 1.273197e-313
55 1.273197e-313
56 1.273197e-313
57 1.273197e-313
58 1.273197e-313
59 1.273197e-313
.....
Starting time loop

Courant Number mean: 5.276506e-05 max: 0.1283081
deltaT = 0.025
Time = 0.025

MULES: Solving for gamma
Liquid phase volume fraction = 0.5 Min(gamma) = 0 Max(gamma) = 1
MULES: Solving for gamma
Liquid phase volume fraction = 0.5 Min(gamma) = 0 Max(gamma) = 1
0 1
1 1
2 0
3 0
4 0
5 0
6 0
7 0
8 3.038e-06
9 3.038e-06
10 3.4544e-08
11 3.4544e-08
12 0
13 0
14 0
15 0
16 0
17 0
18 0
19 0
20 0
21 0
22 0
23 0
24 0
25 0
26 0
27 0
28 0
29 0
30 0
31 0
32 0
33 0
34 0
35 0
36 0
37 0
38 0
39 0
40 0
41 0
42 0
43 0
44 0
45 0
46 0
47 0
48 0
49 0
50 0
51 0
52 0
53 0
54 0
55 0
56 0
57 2.444049e-11
58 2.444049e-11
59 2.444049e-11
DICPCG: Solving for pd, Initial residual = 1, Final residual = 0.04963077, No Iterations 8
DICPCG: Solving for pd, Initial residual = 0.01135738, Final residual = 0.0005306475, No Iterations 10
0 1
1 1
2 0
3 2.500615e-138
4 2.500615e-138
5 3.74594e-132
6 3.74594e-132
7 3.74594e-132
8 2.498814e-05
9 2.498814e-05
10 0.01963497
11 0.01963497
12 0
13 0
14 0
15 0
16 0
17 0
18 0
19 1.580227e-10
20 1.580227e-10
21 1.580227e-10
22 1.959051e-30
23 1.959051e-30
24 5.769587e-114
25 -1.102479e-14
26 -1.102479e-14
27 -1.102479e-14
28 -1.198783e-28
29 -1.198783e-28
30 0
31 -3.565092e-10
32 -3.565092e-10
33 0
34 0
35 -1.426689e-26
36 -1.426689e-26
37 0
38 0
39 0
40 0
41 0
42 0
43 0
44 0.004
45 0
46 0
47 0
48 0
49 0.004
50 0.004
51 0
52 0
53 0
54 0
55 0
56 0
57 2.498814e-05
58 2.498814e-05
59 2.498814e-05
DICPCG: Solving for pd, Initial residual = 0.004856249, Final residual = 9.476824e-08, No Iterations 81
0 1
1 1
2 3.958101e-34
3 2.500615e-138
4 2.500615e-138
5 3.74594e-132
6 3.74594e-132
7 3.74594e-132
8 2.498814e-05
9 2.498814e-05
10 0.01963497
11 0.01963497
12 0
13 0
14 0
15 0
16 0
17 0
18 0
19 1.580227e-10
20 1.580227e-10
21 1.580227e-10
22 1.959051e-30
23 1.959051e-30
24 5.769587e-114
25 1.368002e-07
26 1.368002e-07
27 1.368002e-07
28 -7.210361e-16
29 -7.210361e-16
30 0
31 2.202605e-06
32 2.202605e-06
33 0
34 0
35 2.873679e-29
36 2.873679e-29
37 0
38 0
39 0
40 0
41 0
42 0
43 0
44 1
45 -0
46 -0
47 -0
48 -0
49 1
50 1
51 -0
52 -0
53 -0
54 -0
55 0
56 0
57 2.498814e-05
58 2.498814e-05
59 2.498814e-05
time step continuity errors : sum local = 2.312163e-09, global = -7.946274e-10, cumulative = -5.132373e-06
ExecutionTime = 2.75 s ClockTime = 3 s
........

How could some 100 pop out at the time=0s? Even though the value between 0~1, the values distributing at the inlet boundary are obviously incorrect!!!

How can I fetch the correct transient gamma value in my boundary condition file?

Thank you for your attention!

sega December 8, 2009 15:58

Maybe you should try to use the timeVaryingMappedFixedValue boundary condition if you need transient boundary values.
It will be less work than creating your own boundary condition ...

zhajingjing March 5, 2010 11:15

Maybe a bug!
 
Sorry, it's a little late to tell what I found about this problem.Anyway,better later than never. Maybe somebody will give a detailed explanation on this phenomenon:

If I use this sentence :

const volScalarField& gamma = this->db().objectRegistry::lookupObject<volScalarField> ("gamma");

instead of

fvPatchScalarField& gamma = this->patch().lookupPatchField<volScalarField, scalar>("gamma");

then I get the correct gamma value.

Who can give an explanation?
Thanks.


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