CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Get access to temperature in Openfoam (https://www.cfd-online.com/Forums/openfoam/117429-get-access-temperature-openfoam.html)

hz283 May 14, 2013 12:43

When the momentum equations are solved, the solver crashed. When I comment the calculation of the lamianr and turbulent diffusion terms, the code works, although in this case the diffusivity is missing.

Is this the same as yours?

Quote:

Originally Posted by fredo490 (Post 427373)
Something I really don't understand is that:

basicThermo.C has the following members:
Code:

// Non Constant access to p
Foam::volScalarField& Foam::basicThermo::p()
{
    return p_;
}

// Constant access to p
const Foam::volScalarField& Foam::basicThermo::p() const
{
    return p_;
}

// Constant access to T
const Foam::volScalarField& Foam::basicThermo::T() const
{
    return T_;
}

Then basicThermo.H has the following members:
Code:

        // Access to thermodynamic state variables

            //- Pressure [Pa]
            //  Non-const access allowed for transport equations

            virtual volScalarField& p();

            //- Pressure [Pa]
            virtual const volScalarField& p() const;

            //- Temperature [K]
            virtual const volScalarField& T() const;

Therefor, why the #&{$ adding the same non constant member as p but with T doesn't work ?! If it works for p, why it doesn't work for T ?


fredo490 May 15, 2013 07:16

Yes I get the same problem...

hz283 May 15, 2013 07:17

I think I solved the problem:

Please change to: cd $WM_PROJECT_DIR,

and then run: ./Allwmake.

it will work. have a try and tell me if it works. Thank you.

Quote:

Originally Posted by fredo490 (Post 427677)
Yes I get the same problem...


fredo490 May 15, 2013 12:05

You have found the solution ! Basically what we have to do is to recompile all OpenFoam source code and not only the thermo model.

So after all this, here is the final procedure (tested and approved !):
1) open a text editor in admin by writing in the terminal: "sudo gedit"
2) with this text editor, open: "basicThermo.C" located in /opt/openfoam220/src/thermophysicalModels/basic/basicThermo
3) Add the following line in the Member Functions (I put it at line 396 after the "basicThermo::T()" ):
Code:

// Add this
          //- Temperature [K]
            //  Non-const access allowed
            Foam::volScalarField& Foam::basicThermo::T()
            {
                return T_;
            }

4) with this text editor (still admin), open: "basicThermo.H" located in /opt/openfoam220/src/thermophysicalModels/basic/basicThermo
5) Add the following line after the comment "Fields derived from thermodynamic state variables" (I put it at line 316 after the other Temperature member ):
Code:

// Add this
            //- Temperature [K]
            //  Non-const access allowed for transport equations
            virtual volScalarField& T();

6) Save the two files (To check if it was saved: look at the top of the editor, if the star remains it means that you didn't have the admin / root access).
7) Go to /opt/openfoam220/ and open a terminal
8) With the terminal located in this folder, we now want to get the full root access. To do so, write: "sudo -s". After typing your password, you will see that the command line will start with "root".
9) We need to recompile all OpenFoam. To do so, simply write "./Allwmake". This step might take few minutes depending of your system (for me it took about 45 minutes).

hz283 May 15, 2013 12:07

So happy that we solved this problem finally~~

Quote:

Originally Posted by fredo490 (Post 427777)
You have found the solution ! Basically what we have to do is to recompile all OpenFoam source code and not only the thermo model.

So after all this, here is the final procedure (tested and approved !):
1) open a text editor in admin by writing in the terminal: "sudo gedit"
2) with this text editor, open: "basicThermo.C" located in /opt/openfoam220/src/thermophysicalModels/basic/basicThermo
3) Add the following line in the Member Functions (I put it at line 396 after the "basicThermo::T()" ):
Code:

// Add this
          //- Temperature [K]
            //  Non-const access allowed
            Foam::volScalarField& Foam::basicThermo::T()
            {
                return T_;
            }

4) with this text editor (still admin), open: "basicThermo.H" located in /opt/openfoam220/src/thermophysicalModels/basic/basicThermo
5) Add the following line after the comment "Fields derived from thermodynamic state variables" (I put it at line 316 after the other Temperature member ):
Code:

// Add this
            //- Temperature [K]
            //  Non-const access allowed for transport equations
            virtual volScalarField& T();

6) Save the two files (To check if it was saved: look at the top of the editor, if the star remains it means that you didn't have the admin / root access).
7) Go to /opt/openfoam220/ and open a terminal
8) With the terminal located in this folder, we now want to get the full root access. To do so, write: "sudo -s". After typing your password, you will see that the command line will start with "root".
9) We need to recompile all OpenFoam. To do so, simply write "./Allwmake". This step might take few minutes depending of your system (for me it took about 45 minutes).


fredo490 May 15, 2013 12:14

Haha yeah, actually solving this problem ends my thesis ^^ My simulation runs smoothly and the results are promising.

hz283 May 15, 2013 12:22

Congratulations !

Quote:

Originally Posted by fredo490 (Post 427785)
Haha yeah, actually solving this problem ends my thesis ^^ My simulation runs smoothly and the results are promising.


maHein June 17, 2013 10:52

In case someone tries to implement this, it has also been implemented by the developers into Version 2.2.x commit a9d0f048e1a387af342531d50c79a2d111e2536b.

fredo490 June 17, 2013 11:43

It's a great news ! Thanks for the information ;)


All times are GMT -4. The time now is 04:41.