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/)
-   -   Re: mu in interFoam (https://www.cfd-online.com/Forums/openfoam-programming-development/201192-re-mu-interfoam.html)

Marpole April 24, 2018 15:17

Re: mu in interFoam ...SOLVED
 
I have worked on this for a few days. I need to output mu during an interFoam run so I can see mu field change as water wave shape changes. I wrote the following code and put it in createField.H. I expect that mixture.mu() calculate mu field at each output time. But I found (viewing using paraFoam) that mu field at each output time doesn't change and is the initial mu field where I set it using setFields. Any help is appreciated!

Code:

volScalarField mu
(
    IOobject
    (
        "mu",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT,
        IOobject::AUTO_WRITE
    ),
      mixture.mu()*1.0
);


Bana April 25, 2018 12:55

Hi Marpole

Currently I am kind of struggling with this problem too, try this one:

volScalarField mu
(
IOobject
(
"mu",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mixture.nu()*rho
);

it will write "mu" field in every time step, but it doesn't change over time:(. BTW I want to use "mu" field to add a kinematicCloud to interfoam and I tried this:
basicKinematicTypeCloud kinematicCloud
(
kinematicCloudName,
rho,
U,
mu,
g
);
it works, but I do not know where and how to update the "mu" field and it is important for computing Re number and Drag Coefficient that affects motion of particles.If you have found anything helpful, I will appreciate sharing it with me.

Regards

Marpole April 25, 2018 14:13

Re: mu in interFoam
 
Hi Mohammad,

I will share the solution with if I come up one. So far, I want to give up using mixture.mu() but use something like

Code:

volScalarField mu
(
    IOobject
    (
        "mu",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT,
        IOobject::AUTO_WRITE
    ),
    alpha1*rho1*nu1 + alpha2*rho2*nu2
);

In the above, nu1 and nu2 are from dictionary transportProperties. However, I don't know how to retrieve nu1 and nu2. Do you know how to get those two values?

Regards,

Marpole April 26, 2018 01:33

Re: mu in interFoam
 
Hello Mohammad,

I figured it out. In interFoam, you need add following line within the loop.

Code:

mu = mixture.mu();
Cheers,

Bana April 26, 2018 03:33

Hi Charles,

Thank you very much for sharing your findings. It worked for me too!! I put it right after pimple.loop() and before evolving the cloud.

Best regards,

AnnaF September 3, 2019 03:32

Hi! I just want to add something as it took me a while to realize

To write/load mu into the objectRegistry without declaring it beforehand e.g. in the createFields.H file, one must not forget to declare it in the pimple.loop():

HTML Code:

volScalarField mu = mixture.mu();
:)

Alpha001 October 28, 2020 04:20

Hello,

I am trying to add mu to interFoam as well. (OpenFOam v7)
I have the following:(I have used different color for things that I added

Code:

Info<< "Reading transportProperties\n" << endl;
immiscibleIncompressibleTwoPhaseMixture mixture(U, phi);

volScalarField& alpha1(mixture.alpha1());
volScalarField& alpha2(mixture.alpha2());

const dimensionedScalar& rho1 = mixture.rho1();
const dimensionedScalar& rho2 = mixture.rho2();

const dimensionedScalar& nu1 = mixture.nu1();
const dimensionedScalar& nu2 = mixture.nu2();

volScalarField mu
(
    IOobject
    (
        "mu",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    alpha1*rho1*nu1 + alpha2*rho2*nu2
);

I get the following error
Code:

./createFields.H:107:40: error: ‘class Foam::immiscibleIncompressibleTwoPhaseMixture’ has no member named ‘nu1’; did you mean ‘nu’?
 const dimensionedScalar& nu1 = mixture.nu1();
                                        ^~~
                                        nu
./createFields.H:108:40: error: ‘class Foam::immiscibleIncompressibleTwoPhaseMixture’ has no member named ‘nu2’; did you mean ‘nu’?
 const dimensionedScalar& nu2 = mixture.nu2();
                                        ^~~
                                        nu


Marpole October 29, 2020 12:22

It was a long time ago. Can you help me to explain what you need to do?



If you want just to output mu of the mixture, you can, as Anna F said, declare mu in the loop of interFoam. And in volSaclarField mu in createFields.H, add mixture.mu() to calculate mu for the mixture.



I believe there is no nu1 and nu2 like rho1 and rho2.

renos July 30, 2021 12:31

I have the same problem. Please can you share the code here?

Kind regards,

Renos

Marpole July 30, 2021 17:20

For openfoam-8, you can make two changes as described below.

1. Add a line (highlighted) for computing mu in file interFoam.C before runTime.write().
Code:

          if (pimple.turbCorr())
            {
                turbulence->correct();
            }
        }

        // calculate variable mu
        mu = mixture.mu();


        runTime.write();

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

2. Add a declaration (highlighted) of mu in file createFields.H after the declaration of rho
Code:

// Need to store rho for ddt(rho, U)
volScalarField rho
(
    IOobject
    (
        "rho",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT
    ),
    alpha1*rho1 + alpha2*rho2
);
rho.oldTime();

// declare mu
volScalarField mu
(
    IOobject
    (
        "mu",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    mixture.mu()
);

Good luck with foam!

renos July 31, 2021 05:01

Dear Charles,

Thank you very much for your valuable help and quick response. Now, the solver is compiled without errors!

Kind regards,

Renos


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