CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Better understanding of some unknown parameters in scalarcodedsource (https://www.cfd-online.com/Forums/openfoam-programming-development/153922-better-understanding-some-unknown-parameters-scalarcodedsource.html)

Asghari_M June 6, 2015 14:25

Better understanding of some unknown parameters in scalarcodedsource
 
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

j-avdeev June 7, 2015 09:23

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;

Asghari_M June 8, 2015 04:50

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.

huyidao July 30, 2015 05:03

I also face the same problem right now,do you get the answer?

Asghari_M July 30, 2015 12:53

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.

huyidao July 30, 2015 21:18

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.

SomeUser October 16, 2018 03:32

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!


All times are GMT -4. The time now is 13:36.