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

Explanation of sinusoidal heat source code on fvOptions

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

Like Tree2Likes
  • 1 Post By letoppina
  • 1 Post By überschwupper

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 24, 2022, 03:12
Default Explanation of sinusoidal heat source code on fvOptions
  #1
New Member
 
Giulia
Join Date: Feb 2022
Posts: 19
Rep Power: 4
letoppina is on a distinguished road
Hello,



I am using OpenFoam version 6 and chtMultiRegionFoam as a solver to simulate a solid body (heat source) exchanging heat with a moving fluid. In order to give a sinusoidal variation of the heat source, I am using fvOptions on the solid region with the following code:



Code:
    energySource
    {
        type            scalarCodedSource;
        active          yes;
        timeStart       0;
        duration        1e6;
        name            sourceTime; 
    selectionMode   all;

    scalarCodedSourceCoeffs
        {
        selectionMode   all; 
                volumeMode      specific;           
        fields          (h);
            codeInclude
            #{
            #};

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

            codeAddSup
            #{
                    const Time& time = mesh().time();
                    const scalarField& V = mesh_.V();
                    const vectorField& C = mesh_.C();
                    scalarField& heSource = eqn.source();

            heSource += 2.729e6*sin(2*3.14*0.1*time.value())*V;  

                Pout << "***codeAddSup***" << endl;
            #};

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

            // Dummy entry. Make dependent on above to trigger recompilation
               code
            #{
                    $codeInclude
                    $codeCorrect
                    $codeAddSup
                    $codeSetValue
            #};
        }
My code is properly working but I have some questions:



- what does "const scalarField& V = mesh_.V()" mean?

- what does "const vectorField& C = mesh_.C()" mean?

- why heSource has to be multiplied by V?

- what is a dummy entry?



Any further explication about the code is highly appreciated.



Thank you very much for your help!!
saidc. likes this.
letoppina is offline   Reply With Quote

Old   June 24, 2022, 04:22
Default
  #2
Member
 
Join Date: Jan 2022
Location: Germany
Posts: 72
Rep Power: 4
überschwupper is on a distinguished road
Code:
const scalarField& V = mesh_.V()
const vectorField& C = mesh_.C()

Both are just const references to the cell volume of each cell or cell centers.


Why the heat source is multiplied with V depends on the formulation of the source term. I would guess that the relation derived is normed by the volume and in order get the correct values/dimensions it is multiplied by it.


I dont know the reason or the idea behind a dummy entry. But there are #-symbols has to do with preprocessor directives and inside the directory are the directories defined in your file (for example $AddSup)
letoppina likes this.
überschwupper is offline   Reply With Quote

Old   June 24, 2022, 04:27
Default
  #3
New Member
 
Giulia
Join Date: Feb 2022
Posts: 19
Rep Power: 4
letoppina is on a distinguished road
Quote:
Originally Posted by überschwupper View Post
Code:
const scalarField& V = mesh_.V()
const vectorField& C = mesh_.C()

Both are just const references to the cell volume of each cell or cell centers.


Why the heat source is multiplied with V depends on the formulation of the source term. I would guess that the relation derived is normed by the volume and in order get the correct values/dimensions it is multiplied by it.


I dont know the reason or the idea behind a dummy entry. But there are #-symbols has to do with preprocessor directives and inside the directory are the directories defined in your file (for example $AddSup)
Thank you for your reply!
So this means that if I want to give a heat source not dependent on the volume (so an absolute heat source expressed in W and not W/m3) I just have to remove the multiplication of V?
letoppina is offline   Reply With Quote

Old   June 24, 2022, 05:09
Default
  #4
Member
 
Join Date: Jan 2022
Location: Germany
Posts: 72
Rep Power: 4
überschwupper is on a distinguished road
I cant give you the exact answer to this, because I dont know the exact definiton of your source term. Thats why I mentioned my guess. But it would be the other way as you have written.



Do yoou know the dimensions of the prefactor 2.729e6? Dimensioncontrol could help you here.
überschwupper is offline   Reply With Quote

Reply

Tags
chtmultiregionfoam, fvoptions, heat source, regions, sinusoidal

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
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 04:30
[OpenFOAM.org] Error creating ParaView-4.1.0 OpenFOAM 2.3.0 tlcoons OpenFOAM Installation 13 April 20, 2016 18:34
[foam-extend.org] problem when installing foam-extend-1.6 Thomas pan OpenFOAM Installation 7 September 9, 2015 22:53
[swak4Foam] Swak4FOAM 0.2.3 / OF2.2.x installation error FerdiFuchs OpenFOAM Community Contributions 27 April 16, 2014 16:14
Question about heat transfer coefficient setting for CFX Anna Tian CFX 1 June 16, 2013 07:28


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