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/)
-   -   Adding Boussinesq Approximation to multiphaseInterFoam? (https://www.cfd-online.com/Forums/openfoam-programming-development/221058-adding-boussinesq-approximation-multiphaseinterfoam.html)

Alona October 2, 2019 09:25

Adding Boussinesq Approximation to multiphaseInterFoam?
 
Hello,

I don't kown how to code well in C++ but I'm trying to implement the Boussinesq approximation into the multiphaseInterFoam Solver (OF 4.0). I have succeeded yet with interFoam.

I added a file, T.Eqn with temperature equation and it compiles.

I have trouble with the Boussinesq term, I don't how to deal with it, I tried this in multiphaseMixture.C :

Code:

Foam::tmp<Foam::volScalarField>
Foam::multiphaseMixture::rhoB() const
{
    const volScalarField& T = U_.mesh().lookupObject<volScalarField>("T");
    PtrDictionary<phase>::const_iterator iter = phases_.begin();

    tmp<volScalarField> trhoB = iter()*(iter().rho()*(1.0-iter().beta()*(T-iter().Tref())));
    volScalarField& rhoB = trhoB.ref();

  for (++iter; iter != phases_.end(); ++iter)
  {
        rhoB += iter()*(iter().rho()*(1.0-iter().beta()*(T-iter().Tref())));
  }

  return trhoB;
}


Foam::tmp<Foam::scalarField>
Foam::multiphaseMixture::rhoB(const label patchi) const
{
  PtrDictionary<phase>::const_iterator iter = phases_.begin();

    tmp<scalarField> trhoB = iter().boundaryField()[patchi]*(iter().rho()*(1.0-iter().beta()*(T-iter().Tref())));
  scalarField& rhoB = trhoB.ref();

  for (++iter; iter != phases_.end(); ++iter)
  {
    rhoB += iter().boundaryField()[patchi]*(iter().rho()*(1.0-iter().beta()*(T-iter().Tref())));
  }

  return trhoB;
}

and in multiphaseMixture.H, I add :



Code:

     

  //- Return the mixture variable density
      tmp<volScalarField> rhoB() const;  ////

        //- Return the mixture variable density for patch
        tmp<scalarField> rhoB(const label patchi) const;  ////

rhoB being rho0*(1-beta(T-Tref))

I have this error :
multiphaseMixture.C: In member function ‘Foam::tmp<Foam::Field<double> > Foam::multiphaseMixture::rhoB(Foam::label) const’:
multiphaseMixture.C:233:96: error: no match for ‘operator-’ (operand types are ‘<unresolved overloaded function type>’ and ‘const dimensionedScalar {aka const Foam::dimensioned<double>}’)
tmp<scalarField> trhoB = iter().boundaryField()[patchi]*(iter().rho()*(1.0-iter().beta()*(T-iter().Tref())));
~^~~~~~~~~~~~~~


I don't know how and where define rhoB and T.


Thanks !

ErenC October 8, 2019 16:55

I dont know multiphaseInterFoam but,

There is no rho in buoyancy term. You need to define g(if its not defined in your solver) - beta and Tref in create fields, they are transport properties.

g is vector, beta and Tref are scalars. After that you can add following line to your momentum equation.

Code:

- (g * beta * (T-Tref) )

gowthaman November 20, 2019 18:43

Quote:

Originally Posted by Alona (Post 746039)
Hello,

I don't kown how to code well in C++ but I'm trying to implement the Boussinesq approximation into the multiphaseInterFoam Solver (OF 4.0). I have succeeded yet with interFoam.

I added a file, T.Eqn with temperature equation and it compiles.

I have trouble with the Boussinesq term, I don't how to deal with it, I tried this in multiphaseMixture.C :

Code:

Foam::tmp<Foam::volScalarField>
Foam::multiphaseMixture::rhoB() const
{
    const volScalarField& T = U_.mesh().lookupObject<volScalarField>("T");
    PtrDictionary<phase>::const_iterator iter = phases_.begin();

    tmp<volScalarField> trhoB = iter()*(iter().rho()*(1.0-iter().beta()*(T-iter().Tref())));
    volScalarField& rhoB = trhoB.ref();

  for (++iter; iter != phases_.end(); ++iter)
  {
        rhoB += iter()*(iter().rho()*(1.0-iter().beta()*(T-iter().Tref())));
  }

  return trhoB;
}


Foam::tmp<Foam::scalarField>
Foam::multiphaseMixture::rhoB(const label patchi) const
{
  PtrDictionary<phase>::const_iterator iter = phases_.begin();

    tmp<scalarField> trhoB = iter().boundaryField()[patchi]*(iter().rho()*(1.0-iter().beta()*(T-iter().Tref())));
  scalarField& rhoB = trhoB.ref();

  for (++iter; iter != phases_.end(); ++iter)
  {
    rhoB += iter().boundaryField()[patchi]*(iter().rho()*(1.0-iter().beta()*(T-iter().Tref())));
  }

  return trhoB;
}

and in multiphaseMixture.H, I add :



Code:

     

  //- Return the mixture variable density
      tmp<volScalarField> rhoB() const;  ////

        //- Return the mixture variable density for patch
        tmp<scalarField> rhoB(const label patchi) const;  ////

rhoB being rho0*(1-beta(T-Tref))

I have this error :
multiphaseMixture.C: In member function ‘Foam::tmp<Foam::Field<double> > Foam::multiphaseMixture::rhoB(Foam::label) const’:
multiphaseMixture.C:233:96: error: no match for ‘operator-’ (operand types are ‘<unresolved overloaded function type>’ and ‘const dimensionedScalar {aka const Foam::dimensioned<double>}’)
tmp<scalarField> trhoB = iter().boundaryField()[patchi]*(iter().rho()*(1.0-iter().beta()*(T-iter().Tref())));
~^~~~~~~~~~~~~~


I don't know how and where define rhoB and T.


Thanks !

Hi Alona,
I'm trying to include Boussinesq approximation in interFoam but have some trouble in pressure Eqn. If you are interested, I can share the code or send you an email regarding this.

Many thanks,
Gowthaman


All times are GMT -4. The time now is 08:05.