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 dimensioned scalar/scalar field to chtMultiRegionSimpleFoam/chtMultiRegionFoam (https://www.cfd-online.com/Forums/openfoam-programming-development/224898-adding-dimensioned-scalar-scalar-field-chtmultiregionsimplefoam-chtmultiregionfoam.html)

Lann March 7, 2020 07:36

Adding dimensioned scalar/scalar field to chtMultiRegionSimpleFoam/chtMultiRegionFoam
 
Hi Foamers,

I am currently trying to add electrical potential transport equations to chtMultiRegionSimpleFoam/chtMultiRegionFoam.

However, I failed to add dimensioned scalars and scalar fields to createFields.H (createSolidFields.H) in chtMultiRegionFoam. The way I did is the same as what I did for icoFoam (https://openfoamwiki.net/index.php/H...ure_to_icoFoam)
But it does not work here.

In chtMultiRegionFoam, the createFields.H (createSolidFields.H) file is more complex and it seems that the way of defining scalars is also different, which I don't understand by scanning the code lines.

Does anyone have any idea/experience on this?

Btw I installed Openfoam 5x because it's the latest version that still has chtMultiRegionSimpleFoam, while the later versions combine chtMultiRegionSimpleFoam and chtMultiRegionFoam.

Thanks in advance,

Lan

PositronCascade March 9, 2020 08:00

Would you share what you are trying to do exactly, your modifications and the error that you get? This way is it not possible to guess where you are having a problem.

For v6, v7, you can use chtMultiRegionFoam as well, you just define it as steady problem and it works like old chtMultiRegionSimpleFoam I guess.

Lann March 9, 2020 09:45

Quote:

Originally Posted by PositronCascade (Post 760964)
Would you share what you are trying to do exactly, your modifications and the error that you get? This way is it not possible to guess where you are having a problem.

For v6, v7, you can use chtMultiRegionFoam as well, you just define it as steady problem and it works like old chtMultiRegionSimpleFoam I guess.

Hi Hasan,

Simply speaking, I'm trying to add a transport equation into chtMultiRegionFoam like fvm::laplacian(a, X) == b

My current problem is to implement the parameters / dimensioned scalars (a and b) and the scalar field (X).
In the tutorial that I listed above, it can be done by simply add the lines below into createFields.H:
HTML Code:

Info<< "Reading diffusivity a" << endl;

dimensionedScalar a
(
    transportProperties.lookup("a")
);

Info<< "Reading field fe and fH\n" << endl;

volScalarField X
(
    IOobject
    (
        "X",
        runTime.timeName(),
        solidRegions[i],
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
    ),
    solidRegions[i]
);

However, it does not seem to work in chtMultiRegionFoam. If you could kindly check the createFields.H (createSolidFields.H), you would see the difference. Especially it begins with theses lines:
HTML Code:

    // Initialise solid field pointer lists
    PtrList<coordinateSystem> coordinates(solidRegions.size());
    PtrList<solidThermo> thermos(solidRegions.size());
    PtrList<radiation::radiationModel> radiations(solidRegions.size());
    PtrList<fv::options> solidHeatSources(solidRegions.size());
    PtrList<volScalarField> betavSolid(solidRegions.size());
    PtrList<volSymmTensorField> aniAlphas(solidRegions.size());
    List<bool> residualReachedSolid(solidRegions.size(), true);
    List<bool> residualControlUsedSolid(solidRegions.size(), false);

Any advice and hint may be super helpful for me.

Thanks again,
Lan

crubio.abujas March 9, 2020 10:05

I've been recently trying to adapt chMultiRegionFoam as well. Using OF6 in this my case.

As far as I can understand the code, in this solver the parameters (T, p, rho, ...) are not contained in a single field but each region has its own parameters. In the fluid/createFluidFields.H file a series of PtrList are defined for the magnitudes of interes. Bellow, inside the forAll loop, these properties are read and stored in the list.

Code:

// Initialise fluid field pointer lists
PtrList<rhoReactionThermo> thermoFluid(fluidRegions.size());
PtrList<volScalarField> rhoFluid(fluidRegions.size());
PtrList<volVectorField> UFluid(fluidRegions.size());
PtrList<surfaceScalarField> phiFluid(fluidRegions.size());
PtrList<uniformDimensionedVectorField> gFluid(fluidRegions.size());
PtrList<uniformDimensionedScalarField> hRefFluid(fluidRegions.size());
PtrList<volScalarField> ghFluid(fluidRegions.size());
PtrList<surfaceScalarField> ghfFluid(fluidRegions.size());
PtrList<compressible::turbulenceModel> turbulenceFluid(fluidRegions.size());
PtrList<CombustionModel<rhoReactionThermo>> reactionFluid(fluidRegions.size());
PtrList<volScalarField> p_rghFluid(fluidRegions.size());
PtrList<radiation::radiationModel> radiation(fluidRegions.size());
PtrList<volScalarField> KFluid(fluidRegions.size());
PtrList<volScalarField> dpdtFluid(fluidRegions.size());
PtrList<multivariateSurfaceInterpolationScheme<scalar>::fieldTable>
    fieldsFluid(fluidRegions.size());
PtrList<volScalarField> QdotFluid(fluidRegions.size());

List<scalar> initialMassFluid(fluidRegions.size());

PtrList<IOMRFZoneList> MRFfluid(fluidRegions.size());
PtrList<fv::options> fluidFvOptions(fluidRegions.size());

// Populate fluid field pointer lists
forAll(fluidRegions, i)
{
    Info<< "*** Reading fluid mesh thermophysical properties for region "
        << fluidRegions[i].name() << nl << endl;

    Info<< "    Adding to thermoFluid\n" << endl;
    thermoFluid.set(i, rhoReactionThermo::New(fluidRegions[i]).ptr());
...
}

On this file all the field definition must be present. Afterwards, in the solving loop, you have to point one by one to each regions' field, solve it and pass to the next one. For that the main file calls the fluid/setRegionFluidField.H. These two files must be modified adding the fields you need to add. The equation notation may stay the same as far as the setRegionFluidField pointer names have the same name.


The same things apply to the solid fields, in case you need to modify them.



Hope it helps!

PositronCascade March 10, 2020 03:28

You need to define it in a such way:

Code:

betavSolid.set
        (
            i,
            new volScalarField
            (
                IOobject
                (
                    "betavSolid",
                    runTime.timeName(),
                    solidRegions[i],
                    IOobject::NO_READ,
                    IOobject::NO_WRITE
                ),
                solidRegions[i],
                dimensionedScalar(dimless, scalar(1))
            )
        );

Firstly, you need define i, because you may have many solid regions. you need to define it like, a.set. You need to change mesh with solidRegions[i] or fluidRegions[i].

Lann March 10, 2020 05:40

Thanks Carlos! I'll look into setRegionFluid/SolidField.H


All times are GMT -4. The time now is 01:10.