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

OF v2112: problem with twoPhaseEulerFoam & scalarCodedSource

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 7, 2022, 06:44
Default OF v2112: problem with twoPhaseEulerFoam & scalarCodedSource
  #1
New Member
 
Join Date: Apr 2009
Posts: 12
Rep Power: 15
user is on a distinguished road
Hi foamers,


I use scalarCodedSource for adding mass for a phase in twoPhaseEulerFoam, which used to work in OpenFoam v2012. The same code gives an error "Not implemented" in v2112. A very simple example for fvOptions is:


Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2112                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

testsource
{
    type            scalarCodedSource;
    active          true;
    name           sourceTime; 
   
    scalarCodedSourceCoeffs
    {
        selectionMode   all;
        fields          (thermo:rho.air); 

        codeInclude
        #{
        #};

        codeCorrect
        #{
            Pout<< "**codeCorrect**" << endl;
        #};

        codeAddSup
        #{           
            Info << " addSup " << endl; 
        #};

        codeConstrain
        #{
            Pout<< "**codeConstrain**" << endl;
        #};            

        code
        #{
            $codeInclude
            $codeCorrect
            $codeAddSup
            $codeSetValue
        #};
    }
If I copy this to the bubbleColumn-tutorial (in constant-folder) I get the expected result (giving output text while running) with OF v2012. In OF v2112 I get the error:

Code:
--> FOAM FATAL ERROR: (openfoam-2112)
Not implemented

    From virtual void Foam::fv::sourceTimeFvOptionscalarSource::addSup(const volScalarField&, Foam::fvMatrix<double>&, Foam::label)
    in file /home/user/user-v2112/run/bubbleColumn/constant/fvOptions.testsource.scalarCodedSourceCoeffs at line 59.

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::error::simpleExit(int, bool) at ??:?
#2  Foam::error::exiting(int, bool) at ??:?
#3  Foam::tmp<Foam::fvMatrix<double> > Foam::fv::optionList::operator()<double>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&, Foam::word const&) at ??:?
#4  ? at ??:?
#5  __libc_start_main in /lib64/libc.so.6
#6  ? at ??:?
I guess something changed with accesing the thermofunctions but I couldn't find any big differences for the twoPhaseEulerFoam-solver or twoPhaseSystem, so I guess the problem is something deeper in the code.


Did somebody experience similar issues? A quick test with simpleFoam and the field "k" worked as expected in v2012 and 2112.


Any help is appreciated.


Ulf
user is offline   Reply With Quote

Old   February 7, 2022, 14:11
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,518
Rep Power: 35
olesen will become famous soon enougholesen will become famous soon enough
How does it look if you also define codeAddSupRho ?
Seems to have been missed out on the release notes/upgrade-guides but see the following commit for some info:


https://develop.openfoam.com/Develop...b8b3c23a154725




FWIW the older code that "worked", probably didn't actually use the density.
olesen is offline   Reply With Quote

Old   February 7, 2022, 15:45
Default
  #3
New Member
 
Join Date: Apr 2009
Posts: 12
Rep Power: 15
user is on a distinguished road
Thank your very much for your time and fast answer! As you guessed, codeAddSupRho is the correct way and it seems to work. I'm feeling a little bit ashamed...

I will check the older cases and try to read the release-notes next time more carefully

Ulf
user is offline   Reply With Quote

Old   February 7, 2022, 17:45
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,518
Rep Power: 35
olesen will become famous soon enougholesen will become famous soon enough
Quote:
Originally Posted by user View Post
Thank your very much for your time and fast answer! As you guessed, codeAddSupRho is the correct way and it seems to work. I'm feeling a little bit ashamed...

I will check the older cases and try to read the release-notes next time more carefully

Ulf

Actually I'm not even sure it shows up in the release notes properly at all. Might have slipped under the radar.
olesen is offline   Reply With Quote

Old   April 8, 2022, 21:52
Default
  #5
New Member
 
Juan Salazar
Join Date: Jun 2019
Posts: 19
Rep Power: 5
saladbowl is on a distinguished road
Just for clarification,

If I wish to add a source to the energy equation in rhoPimpleFoam by using fvOptions, then I should define this source in codeAddSupRho? If given source is in units of W/m3, do I need to multiply by rho?

I noticed that in EEqn.H, fvOptions is called with the operator() in the form fvOptions (rho, he).

Code:
{
    volScalarField& he = thermo.he();

    fvScalarMatrix EEqn
    (
        fvm::ddt(rho, he) + fvm::div(phi, he)
      + fvc::ddt(rho, K) + fvc::div(phi, K)
      + (
            he.name() == "e"
          ? fvc::div
            (
                fvc::absolute(phi/fvc::interpolate(rho), U),
                p,
                "div(phiv,p)"
            )
          : -dpdt
        )
      - fvm::laplacian(turbulence->alphaEff(), he)
     ==
        fvOptions(rho, he)
    );
If I understand the C++ code correctly in fvOptionListTemplates.C, then this will run the following lines of code..

Code:
template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator()
(
    const volScalarField& rho,
    GeometricField<Type, fvPatchField, volMesh>& field,
    const word& fieldName
)
{
    checkApplied();

    const dimensionSet ds
    (
        rho.dimensions()*field.dimensions()/dimTime*dimVolume
    );

    tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds));
    fvMatrix<Type>& mtx = tmtx.ref();

    forAll(*this, i)
    {
        option& source = this->operator[](i);

        label fieldi = source.applyToField(fieldName);

        if (fieldi != -1)
        {
            addProfiling(fvopt, "fvOption()." + source.name());

            source.setApplied(fieldi);

            if (source.isActive())
            {
                if (debug)
                {
                    Info<< "Applying source " << source.name() << " to field "
                        << fieldName << endl;
                }

                source.addSup(rho, mtx, fieldi);
            }
        }
    }

    return tmtx;
}
From the above, it is clear that the expected dimensions are `rho.dimensions()*field.dimensions()/dimTime*dimVolume`. I have a bit of difficulty understanding exactly what the call to source.addSup(rho, mtx, fieldi) results in (and where that code is), but I suspect it may insert the scalarCodedSource code from the fvOptions file. Having said that, I imagine that the units for the source should be W/kg, so it is important to multiply a volumetric source by rho. Am I correct in my assessment?
saladbowl is offline   Reply With Quote

Reply

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
fvOptions problem in TwoPhaseEulerFoam mshehata85 OpenFOAM Running, Solving & CFD 14 May 4, 2017 12:31
Fluent Parallelization Problem After AC Power Dropped pawl Hardware 5 November 13, 2016 07:08
area does not match neighbour by ... % -- possible face ordering problem St.Pacholak OpenFOAM 9 November 22, 2011 11:02
natural convection problem for a CHT problem Se-Hee CFX 2 June 10, 2007 07:29
Adiabatic and Rotating wall (Convection problem) ParodDav CFX 5 April 29, 2007 20:13


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