CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to read multiphase parameters in creatFields from Transportproperties ? (https://www.cfd-online.com/Forums/openfoam-programming-development/207889-how-read-multiphase-parameters-creatfields-transportproperties.html)

Amirhosseinesh October 5, 2018 09:22

How to read multiphase parameters in creatFields from Transportproperties ?
 
Hi,


I wrote a new code for Compressible LcmFoam which actually is improved version of LcmFoam for compressible flows. But i have an issue with my phases and parameters , if i give my parameters in creatFields , everything is fine and the solver works properly, but i want to read the parameters from my Transportproperties for multi-phase parameters.
So the question is:
I only have 2 of my parameters from Transportproperties (rho1 , rho2) but i need in my createFields to read the other parameters as well, such as (nu1, nu2) and speed of sound (C_Sound) and etc.


can anyone help me what would be the command for that ?


My Transportproperties would be the following:


/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

phases (resin air);

resin
{
transportModel Newtonian;
nu [0 2 -1 0 0 0 0] 297e-7;
rho [1 -3 0 0 0 0 0] 1110;
}

air
{
transportModel Newtonian;
nu [0 2 -1 0 0 0 0] 14.5e-06;
rho [1 -3 0 0 0 0 0] 1;
}

sigma [1 0 -2 0 0 0 0] 0.0;


// ************************************************** *********************** //





With best regards
Amirhossein

Tobi October 8, 2018 09:56

Hi,
your task requires the generation of an IOdictionary. After you build that object with the correct values, you can access the file and read out different data.
Please check out Doxygen while searching IOdictionary

Amirhosseinesh October 8, 2018 10:34

Dear Tobi,

Thanks for the help. I tried to look it up and search it.
I found a way to do it as following code in my createFields:


Code:

  IOdictionary transportProperties
    (
        IOobject
        (
            "transportProperties",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
        )
    );

    dimensionedScalar nu1_val
    (
    transportProperties.lookup("nu")
    );

but then again i have the error in running my simulation which says for example :"-->



Quote:

FOAM FATAL IO ERROR:
keyword nu is undefined in dictionary "/home/amir/OpenFOAM/amir-5.0/run/CompressibleLcmFoam/Lead_lag_Test/constant/transportProperties"

as you see i already defined nu in my transportProperties as well.

i try to find "nu" first and then if it works other parameters.

With best regards
Amirhossein

Tobi October 8, 2018 14:17

Hi,


no you did not define nu in your file as you should. You defined it within the subdictionary. The code is not smart enough to do it for you. You have to access the subdict first and then nu is found. Otherwise you have to define nu outside the subdicts.

Amirhosseinesh October 12, 2018 10:28

Thanks a lot Tobi,
I have done it with your help and my advisor's help.

For those who wants to do it call something from transportProperties in their createFields, I will put that part of my createFields here , i hope it helps others as well.


creatheFields:

Code:

  IOdictionary transportProperties
    (
        IOobject
        (
            "transportProperties",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
        )
    );


dictionary phase1=transportProperties.subDict("resin");

    dimensionedScalar nu1_val
    (
    phase1.lookup("nu")
    );

    dimensionedScalar rho1_val
    (
    phase1.lookup("rho")
    );

    dimensionedScalar c_sound_resin
    (
    phase1.lookup("c_sound_resin")
    );

    dimensionedScalar p1_0
    (
    phase1.lookup("p1_0")
    );


dictionary phase2=transportProperties.subDict("air");

    dimensionedScalar nu2_val
    (
    phase2.lookup("nu")
    );

    dimensionedScalar rho2_val
    (
    phase2.lookup("rho")
    );

    dimensionedScalar T_val
    (
    phase2.lookup("T_val")
    );

    dimensionedScalar R_s
    (
    phase2.lookup("R_s")
    );


transportProperties:
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  4.0                                  |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "constant";
    object      transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

phases (resin air);

resin
{
    transportModel  Newtonian;
    nu              nu [0 2 -1 0 0 0 0] 3333;
    rho            rho [1 -3 0 0 0 0 0] 2222;
    c_sound_resin    c_sound_resin [0 1 -1 0 0 0 0] 1470;
    p1_0        p1_0 [1 -1 -2 0 0 0 0] 100000;
 
}

air
{
    transportModel  Newtonian;
    nu              nu [0 2 -1 0 0 0 0] 1111;
    rho            rho [1 -3 0 0 0 0 0] 1;
    R_s            R_s [0 2 -2 -1 0 0 0] 287;
    T_val            T_val [0 0 0 1 0 0 0] 293;
}

sigma          [1 0 -2 0 0 0 0] 0.0;

// ************************************************************************* //



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