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

Calculating viscosity as a function of alpha

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 8, 2022, 12:43
Default Calculating viscosity as a function of alpha
  #1
Member
 
Al
Join Date: May 2019
Posts: 37
Rep Power: 7
aliyah. is on a distinguished road
Hello

I want to modify the thermoPhysicalModels library in a way that by changing alpha, viscosity change.
The problem is alpha should be read from mesh and mesh should be defined in defining mu.

The original mu definition that I want to change is located in

openfoam2006/src/thermophysicalModels/specie/transport/polynomial/polynomialTransportI.H

as follow:

Code:
template<class Thermo, int PolySize>
inline Foam::scalar Foam::polynomialTransport<Thermo, PolySize>::mu
(
    const scalar p,
    const scalar T
) const
{
    return muCoeffs_.value(T);
}
So I wan to change it to something like

Code:
template<class Thermo, int PolySize>
inline Foam::scalar Foam::polynomialTransport<Thermo, PolySize>::mu
(
    const scalar p,
    const scalar T
) const
{

const fvMesh& mesh;
const volScalarField& alphaL_ = mesh.lookupObject<volScalarField>("alpha.liquid");
scalar liquidVolume = fvc::domainIntegrate(alphaL_).value(); 

    return muCoeffs_.value(T)/liquidVolume;
}
It will be compiled, but the mesh must be initialized; without initialization, the solver will not work when we attempt to use it.

I looked at some other codes in openfoam and initializing mesh can be done by a code like

Code:
const fvMesh& mesh = alpha1_.mesh();
I tried

Code:
const fvMesh& mesh = this->mesh();

it is not working because this does not have a member named mesh, or .

Code:
const fvMesh& mesh = T.mesh();
which obviously wrong because T is scalar.

So any suggestion how I can initialize mesh here?

Last edited by aliyah.; May 9, 2022 at 03:57.
aliyah. is offline   Reply With Quote

Old   May 12, 2022, 01:50
Default
  #2
Member
 
Join Date: Jan 2022
Location: Germany
Posts: 72
Rep Power: 4
überschwupper is on a distinguished road
Hey,


I'm not sure if this will help you but this is how I would proceed:


This class is templated by a template class Thermo, the constructor of Thermo gets called in the initialisation list. The thermo s are obiously constructed with the input parameter "mesh", but there is no reference variable which stores the adress of mesh (which also means it wont get inherited). Thats where I think you have to go via one of the Field variables, because they store it (take a look at GeomtricField class)


I would try to get the mesh initialised by Thermo::T_.mesh() or by calling the return function Thermo.T().mesh().


I really hope that will help you, but I'm also kind of new in this field



Quote:
Originally Posted by aliyah. View Post
Hello

I want to modify the thermoPhysicalModels library in a way that by changing alpha, viscosity change.
The problem is alpha should be read from mesh and mesh should be defined in defining mu.

The original mu definition that I want to change is located in

openfoam2006/src/thermophysicalModels/specie/transport/polynomial/polynomialTransportI.H

as follow:

Code:
template<class Thermo, int PolySize>
inline Foam::scalar Foam::polynomialTransport<Thermo, PolySize>::mu
(
    const scalar p,
    const scalar T
) const
{
    return muCoeffs_.value(T);
}
So I wan to change it to something like

Code:
template<class Thermo, int PolySize>
inline Foam::scalar Foam::polynomialTransport<Thermo, PolySize>::mu
(
    const scalar p,
    const scalar T
) const
{

const fvMesh& mesh;
const volScalarField& alphaL_ = mesh.lookupObject<volScalarField>("alpha.liquid");
scalar liquidVolume = fvc::domainIntegrate(alphaL_).value(); 

    return muCoeffs_.value(T)/liquidVolume;
}
It will be compiled, but the mesh must be initialized; without initialization, the solver will not work when we attempt to use it.

I looked at some other codes in openfoam and initializing mesh can be done by a code like

Code:
const fvMesh& mesh = alpha1_.mesh();
I tried

Code:
const fvMesh& mesh = this->mesh();
it is not working because this does not have a member named mesh, or .

Code:
const fvMesh& mesh = T.mesh();
which obviously wrong because T is scalar.

So any suggestion how I can initialize mesh here?
überschwupper is offline   Reply With Quote

Old   May 13, 2022, 03:54
Default
  #3
Member
 
Al
Join Date: May 2019
Posts: 37
Rep Power: 7
aliyah. is on a distinguished road
Quote:
Originally Posted by überschwupper View Post
Hey,


I'm not sure if this will help you but this is how I would proceed:


This class is templated by a template class Thermo, the constructor of Thermo gets called in the initialisation list. The thermo s are obiously constructed with the input parameter "mesh", but there is no reference variable which stores the adress of mesh (which also means it wont get inherited). Thats where I think you have to go via one of the Field variables, because they store it (take a look at GeomtricField class)


I would try to get the mesh initialised by Thermo::T_.mesh() or by calling the return function Thermo.T().mesh().


I really hope that will help you, but I'm also kind of new in this field
I appreciate your ideas. I have tried both of your suggestions, but they are both unsuccessful. This is because neither Thermo nor the Thermo::T template class have access to mesh.
aliyah. 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
[Other] mesh airfoil NACA0012 anand_30 OpenFOAM Meshing & Mesh Conversion 13 March 7, 2022 17:22
[mesh manipulation] RefineMesh Error and Foam warning jiahui_93 OpenFOAM Meshing & Mesh Conversion 4 March 3, 2018 11:32
[mesh manipulation] refineMesh Error mohsen.boojari OpenFOAM Meshing & Mesh Conversion 3 March 1, 2018 22:07
alphaEqn.H in twoPhaseEulerFoam cheng1988sjtu OpenFOAM Bugs 15 May 1, 2016 16:12
[blockMesh] error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Meshing & Mesh Conversion 2 March 14, 2012 09:56


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