CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Re: mu in interFoam

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By AnnaF
  • 2 Post By Marpole

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 24, 2018, 15:17
Default Re: mu in interFoam ...SOLVED
  #1
Senior Member
 
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 148
Rep Power: 9
Marpole is on a distinguished road
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
);

Last edited by Marpole; April 26, 2018 at 12:31. Reason: problem solved.
Marpole is offline   Reply With Quote

Old   April 25, 2018, 12:55
Default
  #2
Member
 
Mohammad Reza
Join Date: Sep 2015
Posts: 44
Rep Power: 10
Bana is on a distinguished road
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
Bana is offline   Reply With Quote

Old   April 25, 2018, 14:13
Default Re: mu in interFoam
  #3
Senior Member
 
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 148
Rep Power: 9
Marpole is on a distinguished road
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 is offline   Reply With Quote

Old   April 26, 2018, 01:33
Default Re: mu in interFoam
  #4
Senior Member
 
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 148
Rep Power: 9
Marpole is on a distinguished road
Hello Mohammad,

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

Code:
mu = mixture.mu();
Cheers,
Marpole is offline   Reply With Quote

Old   April 26, 2018, 03:33
Default
  #5
Member
 
Mohammad Reza
Join Date: Sep 2015
Posts: 44
Rep Power: 10
Bana is on a distinguished road
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,

Last edited by Bana; April 26, 2018 at 04:45.
Bana is offline   Reply With Quote

Old   September 3, 2019, 03:32
Default
  #6
Member
 
Anna Feichtner
Join Date: Dec 2016
Location: Cornwall (UK)
Posts: 36
Rep Power: 9
AnnaF is on a distinguished road
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 likes this.
AnnaF is offline   Reply With Quote

Old   October 28, 2020, 04:20
Default
  #7
New Member
 
Prasad ADHAV
Join Date: Apr 2020
Location: Belval, Luxembourg
Posts: 10
Rep Power: 6
Alpha001 is on a distinguished road
Hello,

I am trying to add mu to interFoam as well. (OpenFOam v7)
I have the followingI 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
Alpha001 is offline   Reply With Quote

Old   October 29, 2020, 12:22
Default
  #8
Senior Member
 
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 148
Rep Power: 9
Marpole is on a distinguished road
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.
__________________
Charles L.
Marpole is offline   Reply With Quote

Old   July 30, 2021, 12:31
Default
  #9
New Member
 
renos
Join Date: Dec 2019
Posts: 16
Rep Power: 6
renos is on a distinguished road
I have the same problem. Please can you share the code here?

Kind regards,

Renos
renos is offline   Reply With Quote

Old   July 30, 2021, 17:20
Default
  #10
Senior Member
 
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 148
Rep Power: 9
Marpole is on a distinguished road
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 and S1mple like this.
__________________
Charles L.
Marpole is offline   Reply With Quote

Old   July 31, 2021, 05:01
Default
  #11
New Member
 
renos
Join Date: Dec 2019
Posts: 16
Rep Power: 6
renos is on a distinguished road
Dear Charles,

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

Kind regards,

Renos
renos is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding diffusion term to interFoam transport equation Gearb0x OpenFOAM Programming & Development 3 February 14, 2023 04:16
interFoam vs. simpleFoam channel flow comparison DanM OpenFOAM Running, Solving & CFD 12 January 31, 2020 15:26
interFoam (HELYX-OS) pressure boundary conditions SFr OpenFOAM Running, Solving & CFD 8 June 23, 2016 16:36
k-e & GAMG interFoam Schemitisation Stability Issue JFM OpenFOAM Running, Solving & CFD 3 December 1, 2015 05:58
Problem of InterFoam with LES SpalartAllmarasIDDES keepfit OpenFOAM 3 August 29, 2013 11:21


All times are GMT -4. The time now is 15:25.