CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   chtMultiRegionFoam: meaning of some expressions in the code (https://www.cfd-online.com/Forums/openfoam-solving/165062-chtmultiregionfoam-meaning-some-expressions-code.html)

zfaraday January 8, 2016 14:08

chtMultiRegionFoam: meaning of some expressions in the code
 
Hi everybody!

I have been working for quite a while with chtMultiRegionSimpleFoam, and I know how it works. However, right now I was taking a look at the code and, although I know what it does, due to my weak knowledge on C++ I don't understand a couple of things about it... Here goes a snipet of the solveSolid.H file:
Code:

        tmp<fvScalarMatrix> hEqn
        (
            fvm::ddt(betav*rho, h)
          - (
              thermo.isotropic()
            ? fvm::laplacian(betav*thermo.alpha(), h, "laplacian(alpha,h)")
            : fvm::laplacian(betav*taniAlpha(), h, "laplacian(alpha,h)")
            )
          ==
            fvOptions(rho, h)
        );

I would like to know how betav works, because, as far as I know, it is a coeficient that takes the values 1 or 0, but I cannot understand how it is used by the solver and what its function is...

On the other hand, I would also like to understand how it is interpreted by the solver the following expression
Code:

fvm::laplacian(betav*thermo.alpha(), h, "laplacian(alpha,h)")
because I cannot figure out the meaning of the second laplacian in quotation marks within the first laplacian...

Many thanks in advance!

Best regards,

Alex

wayne14 January 8, 2016 21:54

Quote:

Originally Posted by zfaraday (Post 580135)
Hi everybody!

I have been working for quite a while with chtMultiRegionSimpleFoam, and I know how it works. However, right now I was taking a look at the code and, although I know what it does, due to my weak knowledge on C++ I don't understand a couple of things about it... Here goes a snipet of the solveSolid.H file:
Code:

        tmp<fvScalarMatrix> hEqn
        (
            fvm::ddt(betav*rho, h)
          - (
              thermo.isotropic()
            ? fvm::laplacian(betav*thermo.alpha(), h, "laplacian(alpha,h)")
            : fvm::laplacian(betav*taniAlpha(), h, "laplacian(alpha,h)")
            )
          ==
            fvOptions(rho, h)
        );

I would like to know how betav works, because, as far as I know, it is a coeficient that takes the values 1 or 0, but I cannot understand how it is used by the solver and what its function is...

On the other hand, I would also like to understand how it is interpreted by the solver the following expression
Code:

fvm::laplacian(betav*thermo.alpha(), h, "laplacian(alpha,h)")
because I cannot figure out the meaning of the second laplacian in quotation marks within the first laplacian...

Many thanks in advance!

Best regards,

Alex

Hi Alex,

As far as I know, the second laplacian in quotation marks gives a name to this fvm::laplacian term, so that the following discretization scheme will be used for fvm::laplacian(betav*thermo.alpha(), h) and fvm::laplacian(betav*taniAlpha(), h).

Code:

laplacianSchemes
{
    default            none;
    laplacian(alpha,h)  Gauss linear corrected;
}

For the function of betav, I have no idea due to the lack of knowledge in heat transfer.

Regards,
Yan

zfaraday January 10, 2016 07:51

Hi Yan,

Many thanks for your explanation, that clarifies a lot!

Best regards,

Alex

Bloerb January 11, 2016 13:57

betav is defined in the solver itself (check createSolidFields.H ) and is an additional IOobject. (a file like p U k omega etc)

Code:

// create input output object betavSolidIO
        IOobject betavSolidIO
        (
            "betavSolid",                    // name of the file
            runTime.timeName(),
            solidRegions[i],                // where is it located
            IOobject::MUST_READ,  // must be read
            IOobject::AUTO_WRITE  // is written at each timestep
        );
// check if the object file is properly defined
        if (betavSolidIO.headerOk())
        {
// set a poiner to each region
            betavSolid.set
            (
                i,
                new volScalarField(betavSolidIO, solidRegions[i])
 // creates a volScalarField with the values in the file betavSolid of the region
            );
        }
        else
// if there is no file
        {
            betavSolid.set
            (
                i,
                new volScalarField
                (
                    IOobject
                    (
                        "betavSolid",
                        runTime.timeName(),
                        solidRegions[i],
                        IOobject::NO_READ,        // do not read
                        IOobject::NO_WRITE        // don't write
                    ),
                    solidRegions[i],
                    dimensionedScalar("1", dimless, scalar(1.0))     
 // set it to 1 throughout the domain
                )
            );
        }
    }

The code tells you: If a file named betavSolid exists (headerOK) use betav supplied in the file. If not set 1. It is also dimless hence has no unit.

You can therefore add a file betavSolid into your 0/yoursolidregion/ directory and it will be read. Should look like this
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  3.0.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volScalarField;
    location    "0/solid";
    object      betav;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 0 0 0 0 0 0];

internalField  uniform 1; // or your value

boundaryField
{
// you could also define different values for the patches or use setFields to set it in parts of this region
    ".*"
    {
        type            zeroGradient;
        value          $internalField;
    }
}


// ************************************************************************* //

As to what it is for i am not absolutely certain. But it essentially multiplies with your laplace equation.
Code:

thermo.isotropic()
 ? fvm::laplacian(betav*thermo.alpha(), h, "laplacian(alpha,h)")
 : fvm::laplacian(betav*taniAlpha(), h, "laplacian(alpha,h)")

The ? : part is c++ short for if thermo.isotropic() then ... else ... and chooses the equation solved depending on the thermal conductivity (isotropic or not) alpha.
It is therefore most likely a factor to account for porosity in your solid. (In the combustion solvers betav (beta_nu) is a volume porosity) You can set any value you want not just 0 and 1. You could maybe use it to disable heat conduction in parts of your solid. I would also be interested in the mathematics behind this factor. Let me know if you can find something.

zfaraday February 8, 2016 18:08

Hi Stephan,

First of all, I'm sorry for my late response, I was busy when you provided such an interesting information and I forgot to respond.

Thanks for your detailed explanation about the meaning of betav. That really clarifies! I didn't know that a field called betavSolid could be defined in a solid region. However, I guess that when you define this field, its value will remains constant in time, right? If so, why is it written at each time step? It's quite useless, isn't it? Besides that, I agree with you on the possible meaning of betav, it makes sense that this is a factor that accounts for porosity in the solid. If someone else has any other idea about the meaning of betav, please, let us know!

Quote:

I would also be interested in the mathematics behind this factor. Let me know if you can find something.
I am also interested in getting a thorough knowledge about this factor called here "betav". Any help will be much appreciated!

Best regards,

Alex

derekm April 2, 2018 07:16

Lost in the C++! Can you point me to the file were the values of field thermo.alpha gets assigned from stuff like Kappa, cp and T.

I'm thinking you could use betavSolid to allow for a solid with non-homogenous thermal properties

I found out what I was looking for... and betavSolid is useful.

derekm April 3, 2018 07:41

2 Attachment(s)
I 've attached a pdf that shows in picture the effect of betavSolid simulating a local change in conductivity on the heater temperature distribution in the tutorial chtMultiRegionSimpleFoam multiRegionHeaterRadiation. The case to create it is also included.

Bloerb April 4, 2018 08:19

That is a bit complicated. In the Make/options file you should find inclusions for the thermal libraries (of fluid and solid - for the fluid those are based on turbulence etc so a bit more complicated).
Code:

-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
...
-I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \

and in the solid region itself you will find the creation of the thermo part needed for alpha, thermo.correct etc:
Code:

PtrList<solidThermo> thermos(solidRegions.size());
Which is frequently used in the code later on. Check e.g solveSolid.H. The alpha field is part of solidThermo. solidThermo however does not contain the calculation of alpha! Since solidThermo is the base class all the calculation is done in the actual model. The only choice for this is heSolidThermo. That this is the only choice you have can be checked in thermoPhysicalProperties. Simply try entering something else and look at the error message.

Here alpha is calculated for each cell and for the boundary. A small part of heSolidThermo.C and .H reads:

Code:

        alphaCells[celli] =
            volMixture_.kappa(pCells[celli], TCells[celli])
            /
            mixture_.Cpv(pCells[celli], TCells[celli]);

The volMixture part if you are interessted is defined in basicThermo. And this is basically where the rabbit hole ends.

Hence alpha=kappa/cp.

All of the files you need to look at are
basicThermo
heSolidThermo
solidThermo

Hope that helps

derekm April 7, 2018 11:36

Thanks for that... its clarified a few things. The complexity of the thermo models is probably why the betavSolid field was introduced as a quicker way of making local adjustments. I had looked at making custom heSolidThermo but that would mean a custom solidThermo as well. That also means changing the chtMultiRegionSimpleFoam solver code that references that....


All times are GMT -4. The time now is 18:57.