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

Better understanding of some unknown parameters in scalarcodedsource

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 6, 2015, 14:25
Default Better understanding of some unknown parameters in scalarcodedsource
  #1
Senior Member
 
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16
Asghari_M is on a distinguished road
Hello everyone!
I used scalarCodedSource for definition of a transient heat source.
However, I can't understand the usage of some parameters assigned within the code.
For example, what is meaning of the -= sign at codeAddSup?
If It adds an additional source term to main S= S_u + S_p x, what's philosophy of the minus sign at it?
Or as second question, is codeAddSup an absolute quantity or a specific one?
Or as third question, what’s the meaning of sourceTimeCoeffs in this dynamic code?
Also, these ambiguous parameters are highlighted with red color at a sample scalarCodedSource as follows:
Code:
energySource
{
type scalarCodedSource;
 
activetrue;
selectionMode all;
 
scalarCodedSourceCoeffs
{
fieldNames(h);
redirectType sourceTime;
 
codeInclude
#{
 
#};
 
codeCorrect
#{
Pout<< "**codeCorrect**" << endl;
#};
 
codeAddSup
#{
const Time& time = mesh().time();
const scalarField& V = mesh_.V();
scalarField& heSource = eqn.source();
heSource -= 0.1*sqr(time.value())*V; // Is specific or absolute?
#};
 
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 any help

Last edited by Asghari_M; June 6, 2015 at 17:32.
Asghari_M is offline   Reply With Quote

Old   June 7, 2015, 09:23
Default
  #2
Member
 
Avdeev Evgeniy
Join Date: Jan 2011
Location: Togliatty, Russia
Posts: 69
Blog Entries: 1
Rep Power: 21
j-avdeev will become famous soon enough
Send a message via Skype™ to j-avdeev
Hello, Asghari.

As I remember C++, the following line

Code:
heSource -= 0.1*sqr(time.value())*V;
mean the same as

Code:
heSource = heSource - 0.1*sqr(time.value())*V;
j-avdeev is offline   Reply With Quote

Old   June 8, 2015, 04:50
Default
  #3
Senior Member
 
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16
Asghari_M is on a distinguished road
Ok, of cource this is obvious.
However I didn't get my answer. As a better explanation of my questions, I can restate it as following question:
Suppose there is an energy source term in a simple solid conduction problem according to the following form:
S(h)= t/(t+1)*0.5 (unit is watt/m3 ) :: specific energy source, and
Simple Conduction Equation: ddt(rho, h) - laplacian (k/Cp, h) = enthalpy source term
Now, I want to use scalarCodedSource for definition of heat (enthalpy) source term.
How can I do this operation?
Moreover, the meaning of other unkown parameters such as codeCorrect and sourceTimeCoeffs are still ambiguous for me.

I have presented scalarCodedSource as follows:
( note that I have pointed all of my questions and doubted options for source term and other unknown parameters with red color)
Code:
 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();
scalarField& heSource = eqn.source();
// which expression is correct for above mentioned energy source term??: 
// heSource = time.value()/(time.value()+1)*0.5; //first option (Is it answer?)
// heSource = time.value()/(time.value()+1)*0.5*V; //second option(Is it answer?)
// heSource -= time.value()/(time.value()+1)*0.5;// third option(Is it answer?)
// heSource -= time.value()/(time.value()+1)*0.5*V;// forth option(Is it answer?)
 
#};
 
codeSetValue
#{
Pout<< "**codeSetValue**" << endl;
#};
 
// Dummy entry. Make dependent on above to trigger recompilation
code
#{
$codeInclude
$codeCorrect
$codeAddSup
$codeSetValue ?
#};
}
 
sourceTimeCoeffs ?
{
// Dummy entry
}
}
As you consider, the difference between second and third expression at above code is at using or non-using of minus sign.

Thanks a lot for any other help.

Last edited by Asghari_M; June 27, 2015 at 02:53.
Asghari_M is offline   Reply With Quote

Old   July 30, 2015, 05:03
Default
  #4
New Member
 
nemo
Join Date: Jan 2015
Posts: 26
Rep Power: 11
huyidao is on a distinguished road
I also face the same problem right now,do you get the answer?
huyidao is offline   Reply With Quote

Old   July 30, 2015, 12:53
Default
  #5
Senior Member
 
Mehdi Asghari
Join Date: Feb 2010
Posts: 127
Rep Power: 16
Asghari_M is on a distinguished road
Hi!

Just now, some similar discussions is being discussed in following thread:

http://www.cfd-online.com/Forums/ope...rce-terms.html

You might want to consult the above mentioned thread.
Asghari_M is offline   Reply With Quote

Old   July 30, 2015, 21:18
Default
  #6
New Member
 
nemo
Join Date: Jan 2015
Posts: 26
Rep Power: 11
huyidao is on a distinguished road
Thank you very much.
I still do not understand this problem totally,I think I should read the source code and try to get the answer.
huyidao is offline   Reply With Quote

Old   October 16, 2018, 03:32
Default
  #7
New Member
 
Join Date: Feb 2018
Posts: 3
Rep Power: 8
SomeUser is on a distinguished road
Hi All,

I'm using reactingMultiphaseEulerfoam 3.0 with the fvOptions, scalarCodedSource.
I would like to have two sources, one that is a sink and removes some phase 1 and another source that adds the same mass amount of phase 2.
The mass removed should be dependent on the mass of phase 1.
aka dm1/dt=m1*A

Do someone has any idea how it would be best to do it?

Thanks!
SomeUser is offline   Reply With Quote

Reply

Tags
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
[Commercial meshers] converting Fluent mesh to openfoam standard mesh deepesh OpenFOAM Meshing & Mesh Conversion 31 March 29, 2017 05:59
[Other] How to create an MRF zone ? aminem OpenFOAM Meshing & Mesh Conversion 2 December 8, 2014 10:45
Thermal Comfort Simulation in STAR CCM+ anupmu STAR-CCM+ 1 February 27, 2013 14:25
[OpenFOAM] Saving ParaFoam views and case sail ParaView 9 November 25, 2011 15:46
compressible two phase flow in CFX4.4 youngan CFX 0 July 1, 2003 23:32


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