|
[Sponsors] |
Problem with heat source for OpenFOAM version > 2012 |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 2, 2024, 16:41 |
Problem with heat source for OpenFOAM version > 2012
|
#1 | |
Member
Nikos
Join Date: Aug 2012
Location: Greece
Posts: 30
Rep Power: 14 |
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 #}; } } // ************************************************************************* // Quote:
I would appreciate any feedback or advice! Thanks a lot Nikos |
||
August 2, 2024, 17:00 |
|
#2 | |
Member
Nikos
Join Date: Aug 2012
Location: Greece
Posts: 30
Rep Power: 14 |
I want also to add that the error persists in the case of serial running:
Quote:
Thus, it is probably not an MPI problem.. |
||
August 6, 2024, 12:14 |
|
#3 | ||
Member
Lorenzo
Join Date: Apr 2020
Location: Italy
Posts: 47
Rep Power: 6 |
Hello,
The issue seems to be in the calculation of hSource: Quote:
You can also see the error indicated in FOAM FATAL IO ERROR: Quote:
Lorenzo |
|||
August 6, 2024, 13:19 |
|
#4 | |
Member
Nikos
Join Date: Aug 2012
Location: Greece
Posts: 30
Rep Power: 14 |
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:
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 |
||
August 7, 2024, 04:39 |
|
#5 | |
Member
Lorenzo
Join Date: Apr 2020
Location: Italy
Posts: 47
Rep Power: 6 |
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:
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 |
||
August 7, 2024, 16:23 |
|
#6 | |
Member
Nikos
Join Date: Aug 2012
Location: Greece
Posts: 30
Rep Power: 14 |
Quote:
That was it Lorenzo! Thank you, well appreciated! |
||
Tags |
fvoptions, heat source, scalarcodedsource |
|
|
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 |