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

How to write rho field for incompressible interFoam

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 1 Post By Wenyuan
  • 1 Post By Wenyuan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 27, 2020, 12:23
Default How to write rho field for incompressible interFoam
  #1
New Member
 
Prasad ADHAV
Join Date: Apr 2020
Location: Belval, Luxembourg
Posts: 10
Rep Power: 6
Alpha001 is on a distinguished road
Hello Foamers,

This is my first time asking a question here, so please be patient with any mistakes.

System:
OpenFOAM 7
Ubuntu 18.04LTS

Problem-Statement:
I am trying to couple interFoam to a in-house DEM solver.(Using preCICE)
When using pimpleFoam I could just hard set the values for density and viscocity.
I need the rho and nu field for calculating the Bouyant force on particles. But currently just trying to solve the issue with rho.
In interFoam we have two-phase, so different densities through the domain depending on where you see.

I am using the incompressible interFoam solver.


Changes
I have the following changes in the createFields.H

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();


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

I get the following error when I compile the solver using wmake command.


Code:
./createFields.H: In function ‘int main(int, char**)’:
./createFields.H:110:5: error: expected primary-expression before ‘(’ token
     (
     ^
./createFields.H:115:9: error: expected ‘)’ before ‘IOobject’
         IOobject::AUTO_WRITE
         ^~~~~~~~
In file included from exInterFoam.C:60:0:
createFields.H:110:5: error: expected primary-expression before ‘(’ token
     (
     ^
createFields.H:115:9: error: expected ‘)’ before ‘IOobject’
         IOobject::AUTO_WRITE
         ^~~~~~~~
I am a bit unsure of what I am messing up.
Any tips, advice and help is welcome.


Thank you.
Alpha001 is offline   Reply With Quote

Old   October 27, 2020, 13:33
Default
  #2
New Member
 
Wenyuan Fan
Join Date: Mar 2017
Posts: 27
Rep Power: 9
Wenyuan is on a distinguished road
Hi,

It seems that a comma is missing before the newly added line.
Alpha001 likes this.
Wenyuan is offline   Reply With Quote

Old   October 28, 2020, 01:53
Default
  #3
New Member
 
Prasad ADHAV
Join Date: Apr 2020
Location: Belval, Luxembourg
Posts: 10
Rep Power: 6
Alpha001 is on a distinguished road
Thank you.
It works.
Alpha001 is offline   Reply With Quote

Old   October 28, 2020, 03:39
Default
  #4
New Member
 
Prasad ADHAV
Join Date: Apr 2020
Location: Belval, Luxembourg
Posts: 10
Rep Power: 6
Alpha001 is on a distinguished road
In the above code in createFields.H, how can I add the nu field?

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();

// Getting viscocity
volScalarField nu
(
    IOobject
    (
        "nu",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    alpha1*nu1 + alpha2*nu2
);
I added this, but 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
SO I did some digging and found that in src/transportModels/immiscibleIncompressibleTwoPhaseMixture/immiscibleIncompressibleTwoPhaseMixture.H.
Alpha001 is offline   Reply With Quote

Old   October 28, 2020, 04:19
Default
  #5
New Member
 
Wenyuan Fan
Join Date: Mar 2017
Posts: 27
Rep Power: 9
Wenyuan is on a distinguished road
nu1() and nu2() are not defined in incompressibleTwoPhaseMixture, which is the parent class of immiscibleIncompressibleTwoPhaseMixture.

You can call nu() directly, which returns a tmp<volScalarField>.
Alpha001 likes this.
Wenyuan is offline   Reply With Quote

Old   October 28, 2020, 04:40
Default
  #6
New Member
 
Prasad ADHAV
Join Date: Apr 2020
Location: Belval, Luxembourg
Posts: 10
Rep Power: 6
Alpha001 is on a distinguished road
Thank you. The solver is compiling.
I was also able to write out mu field in the similar way since it is present in incompressibleTwoPhaseMixture.H.


Code:
//- Return the dynamic laminar viscosity
        tmp<volScalarField> mu() const;
Alpha001 is offline   Reply With Quote

Old   July 8, 2021, 00:15
Default
  #7
New Member
 
Abhishek Mukherjee
Join Date: Sep 2014
Posts: 6
Rep Power: 11
absrocks is on a distinguished road
Hi, I want to use turbulence->nut() and turbulence->nu() in interFoam solver, but I am getting the error while compiling
Code:
error: ‘class Foam::incompressibleInterPhaseTransportModel<Foam::immiscibleIncompressibleTwoPhaseMixture>’ has no member named ‘nu’
error: ‘class Foam::incompressibleInterPhaseTransportModel<Foam::immiscibleIncompressibleTwoPhaseMixture>’ has no member named ‘nut’
I am using openfoam2106 version. When I used the same in OpenFOAM-8 it works perfectly. Can anyone have an idea?
If I use mixture->nu() I did not get any error, but how would I access nut?
absrocks is offline   Reply With Quote

Old   October 18, 2021, 12:53
Default
  #8
Member
 
Venkat Ganesh
Join Date: May 2020
Location: Cincinnati, Ohio
Posts: 49
Rep Power: 6
Venky_94 is on a distinguished road
Quote:
Originally Posted by Alpha001 View Post
Thank you. The solver is compiling.
I was also able to write out mu field in the similar way since it is present in incompressibleTwoPhaseMixture.H.


Code:
//- Return the dynamic laminar viscosity
        tmp<volScalarField> mu() const;
Hey, did you check the written out mu and nu values to see if they're right? Because I followed the same procedure as you and my mu and nu values are written out but they're constant values and not the calculated values at each time step.

Did you have to do something in addition to what you have mentioned earlier?
Venky_94 is offline   Reply With Quote

Reply

Tags
createfields, interfoam, rho, write data

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
mesh file for flow over a circular cylinder Ardalan Main CFD Forum 7 December 15, 2020 13:06
[swak4Foam] swakExpression not writing to log alexfells OpenFOAM Community Contributions 3 March 16, 2020 18:19
strange distribution of velocity field when using O-block mesh in interFoam Zhanyuan Wang OpenFOAM 0 December 18, 2019 21:41
pisoFoam with k-epsilon turb blows up - Some questions Heroic OpenFOAM Running, Solving & CFD 26 December 17, 2012 03:34
Phase locked average in run time panara OpenFOAM 2 February 20, 2008 14:37


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