CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Source term in solveTransportPDE (http://www.cfd-online.com/Forums/openfoam/118556-source-term-solvetransportpde.html)

julien.decharentenay May 29, 2013 21:52

Source term in solveTransportPDE
 
Hi,

I have been playing with the "solveTransportPDE" function - which I think is part of swak4Foam - to add passive scalars when using simpleFoam.

I use syntax similar to the following [taken from one of the example]:
Code:

type solveTransportPDE;
outputControl  timeStep;
outputInterval  1;

solveAt timestep;
fieldName TCompare;
steady false;
rho "1" [0 0 0 0 0 0 0];
diffusion "0.01" [0 2 -1 0 0 0 0];
source "0" [0 0 -1 1 0 0 0];
phi "phi" [0 3 -1 0 0];

It is working great. I was looking at trying to specify sources using algebraic expression - such as nominated a source term at a given spatial location (and probably ramping it up in time) for example. I was wondering if anyone had experienced with it/guidance on how to construct the source term. Is multiple line expression allowed?

I was also wondering if the fieldName had to match with the function name?

Thanks in advance for any help/pointer.
Julien

gschaider June 5, 2013 19:55

Quote:

Originally Posted by julien.decharentenay (Post 430871)
Hi,

I have been playing with the "solveTransportPDE" function - which I think is part of swak4Foam - to add passive scalars when using simpleFoam.

I use syntax similar to the following [taken from one of the example]:
Code:

type solveTransportPDE;
outputControl  timeStep;
outputInterval  1;

solveAt timestep;
fieldName TCompare;
steady false;
rho "1" [0 0 0 0 0 0 0];
diffusion "0.01" [0 2 -1 0 0 0 0];
source "0" [0 0 -1 1 0 0 0];
phi "phi" [0 3 -1 0 0];

It is working great. I was looking at trying to specify sources using algebraic expression - such as nominated a source term at a given spatial location (and probably ramping it up in time) for example. I was wondering if anyone had experienced with it/guidance on how to construct the source term. Is multiple line expression allowed?

I was also wondering if the fieldName had to match with the function name?

Thanks in advance for any help/pointer.
Julien

What do you mean with "fieldName had to match with the function name"

Basically in the source term you can do anything you can do with other swak-expressions (so something like "mag(pos()-vector(1,0,0))<0.1 ? (time()<1 ? time() : 1)*42 : 0" would for instance give you a source in a circle around (1,0,0) that grows until t=1 and then stays constant

Multiline: with a variable list you can make this more "structured". BTW: variable are shared between the expressions (rho, diffusion, source, phi): that might help you to make it more consistent

julien.decharentenay June 5, 2013 23:32

Thanks a lot. It is exactly the information I was looking to hear.

Quote:

Originally Posted by gschaider (Post 432304)
What do you mean with "fieldName had to match with the function name"

My post was not very clear [easier to say with hindsight]. In the following sample of code:

Code:

functions {
    TCompare {
        type solveTransportPDE;
        outputControl  timeStep;
        outputInterval  1;

        solveAt timestep;
        fieldName TCompare;
        steady false;
        rho "1" [0 0 0 0 0 0 0];
        diffusion "0.01" [0 2 -1 0 0 0 0];
        source "0" [0 0 -1 1 0 0 0];
        phi "phi" [0 3 -1 0 0];
    }

There are two occurrences of "TCompare". I was referring to the first "TCompare" (2nd line) as being the function name and the second "TCompare" (line 8) as being the fieldName.

I was wondering if the two had to match or if one could nominate a fieldName different from the function name?

gschaider June 6, 2013 05:53

Quote:

Originally Posted by julien.decharentenay (Post 432320)
Thanks a lot. It is exactly the information I was looking to hear.



My post was not very clear [easier to say with hindsight]. In the following sample of code:

Code:

functions {
    TCompare {
        type solveTransportPDE;
        outputControl  timeStep;
        outputInterval  1;

        solveAt timestep;
        fieldName TCompare;
        steady false;
        rho "1" [0 0 0 0 0 0 0];
        diffusion "0.01" [0 2 -1 0 0 0 0];
        source "0" [0 0 -1 1 0 0 0];
        phi "phi" [0 3 -1 0 0];
    }

There are two occurrences of "TCompare". I was referring to the first "TCompare" (2nd line) as being the function name and the second "TCompare" (line 8) as being the fieldName.

I was wondering if the two had to match or if one could nominate a fieldName different from the function name?

No. You can call the functionObject julienLovesLongNamesThatHaveNothingToDoWithWhatThe yName and it would still work. The fieldName is the one that is referred to everywhere else (the field file, fvSchems and fvSolution)


All times are GMT -4. The time now is 21:23.