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

Problem with heat source for OpenFOAM version > 2012

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Lorenzo210
  • 1 Post By nikoscham

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 2, 2024, 16:41
Default Problem with heat source for OpenFOAM version > 2012
  #1
Member
 
Nikos
Join Date: Aug 2012
Location: Greece
Posts: 30
Rep Power: 14
nikoscham is on a distinguished road
Hi all.

I am using the following code, as a fvOptions file, in order to apply a heat source in a specific domain. My solver is the chtMultiRegionSimpleFoam. I have multiple solid and fluid domains. The general workflow of the problem is: meshing->decomposePar->chtMultiRegionSimpleFoam in parallel->reconstructPar.

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

heat_source
{
    type          scalarCodedSource;
    name        sourceTerm_Wa_A;
    active        true;
    
    scalarCodedSourceCoeffs
    {
        fields          (h);
        selectionMode   all;

        codeInclude
        #{

        #};

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

        codeAddSup
        #{

            const Time& time = mesh().time();
            const volScalarField& Tm = mesh_.lookupObject<volScalarField>("T"); 

            const vectorField& C = mesh_.C();
            const scalarField& V = mesh_.V();
            scalarField& hSource = eqn.source();                 //defining source

            forAll(C, i)
            {
                hSource[i] = Tm*V[i];
            }
            Pout << "***codeAddSup***" << endl;
        #};

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

        // Dummy entry. Make dependent on above to trigger recompilation
        code
        #{
            $codeInclude
            $codeCorrect
            $codeAddSup
            $codeSetValue
        #};
    }

}

// ************************************************************************* //
The above code runs without problems in the case of OpenFOAM version 2012. However, when I am trying a newer OF version (e.g. I have tried 2112, 2212, 2312), it crushes at the beginning of chtMultiRegionSimpleFoam, giving only the following "mysterious" output:

Quote:
Using dynamicCode for fvOption::sourceTerm_Wa_A at line 27 in "/home/nikoscham/Downloads/Nr7767/test/system/domain_armor_a/fvOptions.heat_source.scalarCodedSourceCoeffs"
Could not load Could not load "/home/nikoscham/Dow"/home/nikoscham/Downloads/Nr7767/test/dynamicCode/platforms/linux64nloads/Nr7767/test/dynamicCode/platforms/linux64GccDPInt32Opt/lib/GccDPIlibsont32Opt/lib/libsouurceTerm_Wa_A_73dbrceTer76b57m_Wa_A_73db76b5 75727ed286c085e733a5727edc71618b2c8333.so"
286c085e733ac71618b/home/nikoscham/Downloads/Nr7767/test/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTerm_Wa_A_73db76b575727ed286c085e733ac716 18b2c8333.so: cannot open shared object file: No such file or directory
2c8333.so"
/home/nikoscham/Downloads/Nr7767/test/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTerm_Wa_A_73db76b575727ed286c085e733ac716 18b2c8333.so: cannot open shared object file: No such file or directory
Creating new library in "dynamicCode/sourceTerm_Wa_A/platforms/linux64GccDPInt32Opt/lib/libsourceTerm_Wa_A_73db76b575727ed286c085e733ac716 18b2c8333.so"
Invoking wmake libso /home/nikoscham/Downloads/Nr7767/test/dynamicCode/sourceTerm_Wa_A
wmake libso /home/nikoscham/Downloads/Nr7767/test/dynamicCode/sourceTerm_Wa_A
ln: ./lnInclude
dep: codedFvOptionTemplate.C
Ctoo: codedFvOptionTemplate.C
/home/nikoscham/Downloads/Nr7767/test/system/domain_armor_a/fvOptions.heat_source.scalarCodedSourceCoeffs: In member function ‘virtual void Foam::fv::sourceTerm_Wa_AFvOptionscalarSource::add Sup(Foam::fvMatrix<double>&, Foam::label)’:
/home/nikoscham/Downloads/Nr7767/test/system/domain_armor_a/fvOptions.heat_source.scalarCodedSourceCoeffs:50:2 0: error: cannot convert ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘double’ in assignment
/home/nikoscham/Downloads/Nr7767/test/system/domain_armor_a/fvOptions.heat_source.scalarCodedSourceCoeffs:42:1 3: warning: unused variable ‘time’ [-Wunused-variable]
make: *** [/usr/lib/openfoam/openfoam2212/wmake/rules/General/transform:38: Make/linux64GccDPInt32Opt/codedFvOptionTemplate.o] Error 1
[0]
[0]
[0] --> FOAM FATAL IO ERROR: (openfoam-2212 patch=230612)
[0] Failed wmake "dynamicCode/sourceTerm_Wa_A/platforms/linux64GccDPInt32Opt/lib/libsourceTerm_Wa_A_73db76b575727ed286c085e733ac716 18b2c8333.so"
[0]
[0]
[0] file: system/domain_armor_a/fvOptions.heat_source.scalarCodedSourceCoeffs at line 27 to 63.
[0]
[0] From void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const
[0] in file db/dynamicLibrary/codedBase/codedBase.C at line 240.
[0]
FOAM parallel run exiting
[0]
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
with errorcode 1.

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------
I suppose there is some problem with the MPI during the compilation of the scalarCodedSource in fvOptions. For that reason, I have tried it on both native Linux (Mint 20.3) and WSL, in order to check if there is any problems with the gcc compiler. I have also tried different Ubuntu versions on WSL (20.04 and 22.04). Unfortunately, the results are the same in all my attempts.. It only runs with OpenFOAM 2012.

I would appreciate any feedback or advice!
Thanks a lot
Nikos
nikoscham is offline   Reply With Quote

Old   August 2, 2024, 17:00
Default
  #2
Member
 
Nikos
Join Date: Aug 2012
Location: Greece
Posts: 30
Rep Power: 14
nikoscham is on a distinguished road
I want also to add that the error persists in the case of serial running:

Quote:
Using dynamicCode for fvOption::sourceTerm_Wa_A at line 27 in "/home/nikoscham/Downloads/Nr7767/test/system/domain_armor_a/fvOptions.heat_source.scalarCodedSourceCoeffs"
Could not load "/home/nikoscham/Downloads/Nr7767/test/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTerm_Wa_A_73db76b575727ed286c085e733ac716 18b2c8333.so"
/home/nikoscham/Downloads/Nr7767/test/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTerm_Wa_A_73db76b575727ed286c085e733ac716 18b2c8333.so: cannot open shared object file: No such file or directory
Creating new library in "dynamicCode/sourceTerm_Wa_A/platforms/linux64GccDPInt32Opt/lib/libsourceTerm_Wa_A_73db76b575727ed286c085e733ac716 18b2c8333.so"
Invoking wmake libso /home/nikoscham/Downloads/Nr7767/test/dynamicCode/sourceTerm_Wa_A
wmake libso /home/nikoscham/Downloads/Nr7767/test/dynamicCode/sourceTerm_Wa_A
ln: ./lnInclude
dep: codedFvOptionTemplate.C
Ctoo: codedFvOptionTemplate.C
/home/nikoscham/Downloads/Nr7767/test/system/domain_armor_a/fvOptions.heat_source.scalarCodedSourceCoeffs: In member function ‘virtual void Foam::fv::sourceTerm_Wa_AFvOptionscalarSource::add Sup(Foam::fvMatrix<double>&, Foam::label)’:
/home/nikoscham/Downloads/Nr7767/test/system/domain_armor_a/fvOptions.heat_source.scalarCodedSourceCoeffs:50:2 0: error: cannot convert ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘double’ in assignment
/home/nikoscham/Downloads/Nr7767/test/system/domain_armor_a/fvOptions.heat_source.scalarCodedSourceCoeffs:42:1 3: warning: unused variable ‘time’ [-Wunused-variable]
make: *** [/usr/lib/openfoam/openfoam2212/wmake/rules/General/transform:38: Make/linux64GccDPInt32Opt/codedFvOptionTemplate.o] Error 1


--> FOAM FATAL IO ERROR: (openfoam-2212 patch=230612)
Failed wmake "dynamicCode/sourceTerm_Wa_A/platforms/linux64GccDPInt32Opt/lib/libsourceTerm_Wa_A_73db76b575727ed286c085e733ac716 18b2c8333.so"


file: system/domain_armor_a/fvOptions.heat_source.scalarCodedSourceCoeffs at line 27 to 63.

From void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const
in file db/dynamicLibrary/codedBase/codedBase.C at line 240.

FOAM exiting

Thus, it is probably not an MPI problem..
nikoscham is offline   Reply With Quote

Old   August 6, 2024, 12:14
Default
  #3
Member
 
Lorenzo
Join Date: Apr 2020
Location: Italy
Posts: 47
Rep Power: 6
Lorenzo210 is on a distinguished road
Hello,

The issue seems to be in the calculation of hSource:

Quote:
forAll(C, i)
{
hSource[i] = Tm*V[i];
}
It should be Tm[i]. Since Tm is a volScalarField&, the code needs to pick the -i cell value.

You can also see the error indicated in FOAM FATAL IO ERROR:

Quote:
fvOptions.heat_source.scalarCodedSourceCoeffs:50:2 0: error: cannot convert ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘double’ in assignment
Cheers,
Lorenzo
Lorenzo210 is offline   Reply With Quote

Old   August 6, 2024, 13:19
Cool
  #4
Member
 
Nikos
Join Date: Aug 2012
Location: Greece
Posts: 30
Rep Power: 14
nikoscham is on a distinguished road
You are right. That was one problem, but not what I was looking for!
Let my explain. I have removed some terms in order to simplify the source (for demonstration reasons) and it seems that I accidentally removed also the [i] part from Tm. Thus, unfortunately, that was not my problem. The error log now is:


Quote:
Using dynamicCode for fvOption::sourceTerm_Wa_A at line 27 in "/home/nikoscham/Downloads/Nr7767/test/system/domain_armor_a/fvOptions.heat_source.scalarCodedSourceCoeffs"
Could not load "/home/nikoscham/Downloads/Nr7Could not load "767/test/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTerm_W/home/nikoscham/Downloads/Nr7767/test/dynamicCode/platforms/lina_A_9825ux64GccDPInt32Opt/lbdb0b00cacf519a0680eib/libefa56sourceTerm_Wa_Ac1f5a89d406.so"_9825b
/home/nikoscham/Downloads/Nr7767/test/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTerm_Wa_A_9825bdb0b00cacf519a0680eefa56c1 f5a89d406.so: cannot open shared object file: No such file or directory
db0b00cacf519a0680eefa56c1f5a89d406.so"
/home/nikoscham/Downloads/Nr7767/test/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libsourceTerm_Wa_A_9825bdb0b00cacf519a0680eefa56c1 f5a89d406.so: cannot open shared object file: No such file or directory
Creating new library in "dynamicCode/sourceTerm_Wa_A/platforms/linux64GccDPInt32Opt/lib/libsourceTerm_Wa_A_9825bdb0b00cacf519a0680eefa56c1 f5a89d406.so"
Invoking wmake libso /home/nikoscham/Downloads/Nr7767/test/dynamicCode/sourceTerm_Wa_A
wmake libso /home/nikoscham/Downloads/Nr7767/test/dynamicCode/sourceTerm_Wa_A
ln: ./lnInclude
dep: codedFvOptionTemplate.C
Ctoo: codedFvOptionTemplate.C
/home/nikoscham/Downloads/Nr7767/test/system/domain_armor_a/fvOptions.heat_source.scalarCodedSourceCoeffs: In member function ‘virtual void Foam::fv::sourceTerm_Wa_AFvOptionscalarSource::add Sup(Foam::fvMatrix<double>&, Foam::label)’:
/home/nikoscham/Downloads/Nr7767/test/system/domain_armor_a/fvOptions.heat_source.scalarCodedSourceCoeffs:42:1 3: warning: unused variable ‘time’ [-Wunused-variable]
link: /home/nikoscham/Downloads/Nr7767/test/dynamicCode/sourceTerm_Wa_A/../platforms/linux64GccDPInt32Opt/lib/libsourceTerm_Wa_A_9825bdb0b00cacf519a0680eefa56c1 f5a89d406.so
Selecting finite volume options type sourceTerm_Wa_A
Source: sourceTerm_Wa_A
- selecting all cells
- selected 100800 cell(s) with volume 0.02605784
[0]
[1]
[1]
[1] --> FOAM FATAL ERROR: (openfoam-[0]
[0] --> FOAM FATAL ERROR: (openfoam-2212 patch=230612)
[0] Not implemented
[0]
[0] From virtual void Foam::fv::sourceTerm_Wa_AFvOptionscalarSource::add Sup(const volScalarField&, Foam::fvMatrix<double>&, Foam::label)
[0] in file /home/nikoscham/Downloads/Nr7767/test/system/domain_armor_a/fvOptions.heat_source.scalarCodedSourceCoeffs2212 patch=230612)
[1] Not implemented
[1]
[1] From virtual void Foam::fv::sourceTerm_Wa_AFvOptionscalarSource::add Sup(const volScalarField&, Foam::fvMatrix<double>&, Foam::label)
[1] in file /home/nikoscham/Downloads/Nr7767/test/system/domain_armor_a/fvOptions.heat_source.scalarCodedSourceCoeffs at line 72.
[1]
FOAM parallel run aborting
[1]
at line 72.
[0]
FOAM parallel run aborting
[0]
[0] #0 [1] #0 Foam::error:rintStack(Foam::Ostream&)Foam::error :rintStack(Foam::Ostream&) in in /usr/lib/openfoam/openfoam2212/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so
/usr/lib/openfoam/openfoam2212/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so
[1] #1 [0] #1 Foam::error::simpleExit(int, bool)Foam::error::simpleExit(int, bool) in /usr/lib/openfoam/openfoam2212/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so
in /usr/lib/openfoam/openfoam2212/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so
[0] #2 [1] #2 Foam::error::exiting(int, bool)Foam::error::exiting(int, bool) in in /usr/lib/openfoam/openfoam2212/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so
/usr/lib/openfoam/openfoam2212/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so
[0] #3 [1] #3 Foam::tmp<Foam::fvMatrix<double> > Foam::fv:ptionList:perator()<double>(Foam::Geo metricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&, Foam::word const&)Foam::tmp<Foam::fvMatrix<double> > Foam::fv:ptionList:perator()<double>(Foam::Geo metricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&, Foam::word const&) in in /usr/lib/openfoam/openfoam2212/platforms/linux64GccDPInt32Opt/bin/chtMultiRegionSimpleFoam
/usr/lib/openfoam/openfoam2212/platforms/linux64GccDPInt32Opt/bin/chtMultiRegionSimpleFoam
[1] #4 [0] #4 ?? in in /usr/lib/openfoam/openfoam2212/platforms/linux64GccDPInt32Opt/bin/chtMultiRegionSimpleFoam
/usr/lib/openfoam/openfoam2212/platforms/linux64GccDPInt32Opt/bin/chtMultiRegionSimpleFoam
[0] #5 __libc_start_main[1] #5 __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6 in /lib/x86_64-linux-gnu/libc.so.6

[0] #6 [1] #6 ?? in in /usr/lib/openfoam/openfoam2212/platforms/linux64GccDPInt32Opt/bin/chtMultiRegionSimpleFoam
/usr/lib/openfoam/openfoam2212/platforms/linux64GccDPInt32Opt/bin/chtMultiRegionSimpleFoam
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
with errorcode 1.

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------
[Attis:03617] 1 more process has sent help message help-mpi-api.txt / mpi-abort
[Attis:03617] Set MCA parameter "orte_base_help_aggregate" to 0 to see all help / error messages

The (corrected) code now is:

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

heat_source
{
    type          scalarCodedSource;
    name          sourceTerm_Wa_A;
    active        true;
    

    scalarCodedSourceCoeffs
    {
        fields          (h);
        selectionMode   all; // all, cellSet, cellZone, points

        codeInclude
        #{

        #};

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

        codeAddSup
        #{

            const Time& time = mesh().time();
            const volScalarField& Tm = mesh_.lookupObject<volScalarField>("T"); 
            const vectorField& C = mesh_.C();                    //List of cellcentres
            const scalarField& V = mesh_.V();                    //Volume of an individual cell in the cellZone
            scalarField& hSource = eqn.source();                 //defining source

            forAll(C, i)
            {
                hSource[i] = Tm[i]*V[i];
            }
            Pout << "***codeAddSup***" << endl;
        #};

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

        // Dummy entry. Make dependent on above to trigger recompilation
        code
        #{
            $codeInclude
            $codeCorrect
            $codeAddSup
            $codeSetValue
        #};
    }

}

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

Thanks for your reply anyway!
Best regards,
Nikos
nikoscham is offline   Reply With Quote

Old   August 7, 2024, 04:39
Default
  #5
Member
 
Lorenzo
Join Date: Apr 2020
Location: Italy
Posts: 47
Rep Power: 6
Lorenzo210 is on a distinguished road
Hi,
Also my bad because I tried the corrected script only with OpenFOAM-v2012


It looks like scalarCodedSource has been modified to distinguish between incompressible and compressible cases.


Have a look at this post:

OF v2112: problem with twoPhaseEulerFoam & scalarCodedSource


As suggested here, you could try using "codedAddSupRho" instead of "codedAddSup".


I guess this is the case, we can see in chtMultiRegionSimpleFoam/fluid/EEqn.H that the source term is called with "rho":


Quote:
16 + fvOptions(rho, he)

It would be interesting to see if there is any difference in the calculations, comparing the codes or the results from the older version.



Regards,
Lorenzo
nikoscham likes this.
Lorenzo210 is offline   Reply With Quote

Old   August 7, 2024, 16:23
Default
  #6
Member
 
Nikos
Join Date: Aug 2012
Location: Greece
Posts: 30
Rep Power: 14
nikoscham is on a distinguished road
Quote:
Originally Posted by Lorenzo210 View Post
Hi,
Also my bad because I tried the corrected script only with OpenFOAM-v2012


It looks like scalarCodedSource has been modified to distinguish between incompressible and compressible cases.


Have a look at this post:

OF v2112: problem with twoPhaseEulerFoam & scalarCodedSource


As suggested here, you could try using "codedAddSupRho" instead of "codedAddSup".


I guess this is the case, we can see in chtMultiRegionSimpleFoam/fluid/EEqn.H that the source term is called with "rho":





It would be interesting to see if there is any difference in the calculations, comparing the codes or the results from the older version.



Regards,
Lorenzo

That was it Lorenzo! Thank you, well appreciated!
Lorenzo210 likes this.
nikoscham is offline   Reply With Quote

Reply

Tags
fvoptions, heat source, scalarcodedsource


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
[OpenFOAM.org] Patches to compile OpenFOAM 2.2 on Mac OS X gschaider OpenFOAM Installation 136 October 10, 2017 18:25
polynomial BC srv537 OpenFOAM Pre-Processing 4 December 3, 2016 10:07
[Other] How to use finite area method in official OpenFOAM 2.2.0? Detian Liu OpenFOAM Meshing & Mesh Conversion 4 November 3, 2015 04:04
Problem compiling a custom Lagrangian library brbbhatti OpenFOAM Programming & Development 2 July 7, 2014 12:32
Trouble compiling utilities using source-built OpenFOAM Artur OpenFOAM Programming & Development 14 October 29, 2013 11:59


All times are GMT -4. The time now is 14:49.