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

Assigning time dependent heat Source terms

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 1, 2015, 15:40
Default
  #21
Senior Member
 
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18
hk318i is on a distinguished road
You are right, usually I check the source code to get a definitive answer. Additionally, some code testing could be needed to better understand how certain parts of OF really works.
hk318i is offline   Reply With Quote

Old   August 2, 2015, 01:50
Default
  #22
Senior Member
 
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16
Asghari_M is on a distinguished road
Quote:
Originally Posted by hk318i View Post
You are right, usually I check the source code to get a definitive answer. Additionally, some code testing could be needed to better understand how certain parts of OF really works.
Hi.
I prefer to trace/search the part of main program of OF recalling hesource at following scalarCodedSource code:
Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

energySource 
{ 
type            scalarCodedSource;
    active          true;
    selectionMode   all;
  

    scalarCodedSourceCoeffs
    {
        fieldNames      (h);
        redirectType    sourceTime;
        codeInclude
        #{

        #};

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

        codeAddSup
        #{
            const Time& time = mesh().time();
            const scalarField& V = mesh_.V();
            const vectorField& C = mesh_.C();
             // How & where (which sub-program) does main program (source code) read/recall hesource?//
            scalarField& heSource = eqn.source();
            scalar hs = (2.0*time.value())/(1+time.value());
     
//   heSource +=  hs 
              .OR.
     heSource +=  hs*V;//
    Pout << "***codeAddSup***" << endl;
        #};

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

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

    sourceTimeCoeffs
    {
        // Dummy entry
    }
Can u help me in how to find hesource in main program? In other words, how& where does main program use hesource as output of scalarCodedSource? How is the hesource transferred within subroutines?
I'd appreciated for any help.

Last edited by Asghari_M; August 2, 2015 at 04:12.
Asghari_M is offline   Reply With Quote

Old   August 2, 2015, 10:06
Default
  #23
Senior Member
 
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18
hk318i is on a distinguished road
Tomislav Maric post about fvOptions is very good starting point to understand how fvOptions works. [LINK].

I can confirm two points here, first the source term "he" should have units of Watts [Kg m2 S-3]. Secondary the heSource should be (heSource-= hs) or (he = -hs) too act as source otherwise it will act as sink. I think that could explain the drop in Temperature in your case.
hk318i is offline   Reply With Quote

Old   August 2, 2015, 16:23
Smile
  #24
Senior Member
 
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16
Asghari_M is on a distinguished road
Hello Hassan.
I conclude the correct scalarCodedSource type of fvOptions for my heat source is based on ur points as follows:

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

energySource 
{ 
type            scalarCodedSource;
    active          true;
    selectionMode   all;
  

    scalarCodedSourceCoeffs
    {
        fieldNames      (h);
        redirectType    sourceTime;
        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();
            scalar hs = (2.0*time.value())/(1+time.value());
     // the correct relation for hesource is presented as follows: // 
  heSource -=  hs*V;//Isn't it?//
    Pout << "***codeAddSup***" << endl;
        #};

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

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

    sourceTimeCoeffs
    {
        // Dummy entry
    }
Thanks a lot for your all helpful answers during this thread.

M.Asghari
Asghari_M is offline   Reply With Quote

Old   August 2, 2015, 16:35
Default
  #25
Senior Member
 
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18
hk318i is on a distinguished road
Yes, it looks good. Give it a try and see the results. Please keep us updated.
Best wishes,
Hassan
__________________
@HIKassem | HassanKassem.me
hk318i is offline   Reply With Quote

Old   August 3, 2015, 01:19
Default
  #26
Senior Member
 
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16
Asghari_M is on a distinguished road
conclusion:
Really, since my heat source term is specific and scalarCodedsource returns absolute value as heSource (in watt unit), user should use *V notation (multiplying hesource by mesh volume) for scalarCodedSource type in fvOptions.
Best Wishes
SHUBHAM9595 likes this.
Asghari_M is offline   Reply With Quote

Reply


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
Transient spacial dependent heat source Kumudu OpenFOAM Running, Solving & CFD 0 October 28, 2013 12:02
same geometry,structured and unstructured mesh,different behaviour. sharonyue OpenFOAM Running, Solving & CFD 13 January 2, 2013 23:40
plot over time fferroni OpenFOAM Post-Processing 7 June 8, 2012 08:56
friction forces icoFoam ofslcm OpenFOAM 3 April 7, 2012 11:57
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 12:44


All times are GMT -4. The time now is 04:22.