I'm doing a RTD (Residence Time Distribution) of a 3D cylinder. I solved the velocity part by using simpleFoam in a steady state.
Then, with this converged velocity I created a similar case (with scalarTransportFoam, transient), including a step experiment at the beginning.
By measuring the Heat flux at the "outlet" patch, I would manage to study this RTD. (Hope you got everything)

My case briefly presented, here's my question:

in the controlDict file, I want to use a function to calculate the integral for the product (Ux*T) during the whole calculation (t= 0 -> 3 with dt=2.5e-3)

@your recent posting: the factor always has to be a number that's why Ux didn't work. If you know the velocity you'd have to hardcode it here.

As what you're trying to compute isn't THAT uncommon SFO has a functionObject patchFieldFlow to do it (for compressible flow there is also a rho there, but that's alright I guess)

simpleFunctionObjects can't do arbitray calculations (Ux*T or so) on patches BUT swak4Foam can. The functionObjects there that can do that are patchExpression or swakExpression and they are based on SFO

@your recent posting: the factor always has to be a number that's why Ux didn't work. If you know the velocity you'd have to hardcode it here.

As what you're trying to compute isn't THAT uncommon SFO has a functionObject patchFieldFlow to do it (for compressible flow there is also a rho there, but that's alright I guess)

simpleFunctionObjects can't do arbitray calculations (Ux*T or so) on patches BUT swak4Foam can. The functionObjects there that can do that are patchExpression or swakExpression and they are based on SFO

Bernhard

Hi Bernhard,

First of all: thanks for your answer !

I was doing some tries with swak4foam before I saw your reply.
First of them, I tried to change (naively...) the "functionObjectsLibs" into that:

Remarque: 1) The huge amount of libraries at the end isn't required (only some would be necessary). I just have them from a previous case and didn't optimize it.
2) I'm not sure if the dflux "patches" is correct or if the calculation is made everywhere...

As I said, it's highly inefficient compare to what's possible to do, but that's a start.
I wait for your comments before putting my example in the swak4foam wiki (if it's not too crappy)

Remarque: 1) The huge amount of libraries at the end isn't required (only some would be necessary). I just have them from a previous case and didn't optimize it.
2) I'm not sure if the dflux "patches" is correct or if the calculation is made everywhere...

As I said, it's highly inefficient compare to what's possible to do, but that's a start.
I wait for your comments before putting my example in the swak4foam wiki (if it's not too crappy)

Have a nice weekend

Hi.

You don't have to go through the expressionField. libsimpleSwakFunctionObjects.so already has what you need:

I didn't want to use the patchExpression with "sum" because I thought it was only for an addition. I didn't push it further...

Quote:

If you want the actual amount of T (which still is not the energy) flowing out this is better
Code:
temperatureSum
{
type patchExpression;
accumulations (
sum
);
patches (
outlet
);
expression "phi*T";
verbose true;
}
But if you had wanted that you would have used the patchFieldFlow from the simpleFunctionObjects

Exactly

[EDIT]: I tried to use your expression (to compare results) but I'm having some trouble with. It can't find the "linsimpleSwakFunctionObjects.so" apparently. Don't know what's wrong, I did "wclean" and "wmake" again, but it seems there's a problem with it. With OF1.7, I guess that's normal (as you put in your README) but with OF1.6dev, it should work...

To get to grips with the simpleFunctionObjects and swak4Foam I created a modified PD case to pisoFoam and injected scalarTransport into it - scalar T. I want to track the very uninteresting change of T in the domain and on the boundary. In the blockMeshDict I named all my blocks "domain".

I failed to create an expression for the difference of patchFieldFlow @ the inlet and outlet - main aim is to replicate the sumT expression with only boundary information only. Later I realized that I cannot reproduce the patchFieldFlow simpleFuncuntionObject with swak ...

At first I tried to somehow name (save) the two patchFieldFlow and make a subtraction. Is it possible to name / save it or to combine this with swak4Foam? My pure swak was crap as well ...

For the new sumT expression the timeStep information is necessary, how can one obtain the timeStep within swak?

There's some very similar stuff in the Examples / groovyBC / pulsedPitzDaily but I couldn't put it into practise.

To get to grips with the simpleFunctionObjects and swak4Foam I created a modified PD case to pisoFoam and injected scalarTransport into it - scalar T. I want to track the very uninteresting change of T in the domain and on the boundary. In the blockMeshDict I named all my blocks "domain".

I failed to create an expression for the difference of patchFieldFlow @ the inlet and outlet - main aim is to replicate the sumT expression with only boundary information only. Later I realized that I cannot reproduce the patchFieldFlow simpleFuncuntionObject with swak ...

At first I tried to somehow name (save) the two patchFieldFlow and make a subtraction. Is it possible to name / save it or to combine this with swak4Foam? My pure swak was crap as well ...

For the new sumT expression the timeStep information is necessary, how can one obtain the timeStep within swak?

There's some very similar stuff in the Examples / groovyBC / pulsedPitzDaily but I couldn't put it into practise.

Sorry for not answering to your post in more detail, but at a first glance I'd say that there is a slight misunderstanding on the definition of phi:http://openfoamwiki.net/index.php/Ma...ver_is_writing
That means multiplying the surface is not necessary (actually it is wrong).

Also remote variables only work correctly if they are uniform. So for your difference you'll have to do the sums on the patches (inFlowT{inlet}=sum(phi*T)) and on the internalField accumulate the difference with min, max or average (they all should give the same result).

Whether checking for the "conservation of temperature" makes physical sense of course depends on your solver

The only thing that still puzzles me is the slight difference in the the values - volume integration of the scalar and the calculated value based on the boundary flows. The latter gets accumulated in a variable, so there will be some error as the simulation progresses. But what causes the relatively big difference at the start, and the error wouldn't grow afterward, albeit it is not constant - quite strange! Attached the plots.

I attach the case since I usually find them quite useful if there's an attached project on the threads. So, the attachment contains a very simple extended pisoFoam solver with a scalar transport equation in it. The case is the pitzDaily with a scalar injected on the inlet. I used groovyBC to partition just the middle section of the inlet. I use simpleFunctionObjects and swakExpressions to track the evolution of the T scalar in the domain. I tried to replicate some functionalities with swak just to get some things sorted and learn a bit. At the end of the simulation pyFoam generates the plots.

The only thing that still puzzles me is the slight difference in the the values - volume integration of the scalar and the calculated value based on the boundary flows. The latter gets accumulated in a variable, so there will be some error as the simulation progresses. But what causes the relatively big difference at the start, and the error wouldn't grow afterward, albeit it is not constant - quite strange! Attached the plots.

I attach the case since I usually find them quite useful if there's an attached project on the threads. So, the attachment contains a very simple extended pisoFoam solver with a scalar transport equation in it. The case is the pitzDaily with a scalar injected on the inlet. I used groovyBC to partition just the middle section of the inlet. I use simpleFunctionObjects and swakExpressions to track the evolution of the T scalar in the domain. I tried to replicate some functionalities with swak just to get some things sorted and learn a bit. At the end of the simulation pyFoam generates the plots.

Sorry. I currently don't have the time to have a look at the case.

Anyway: I don't think that the initial error is something to worry about. The relative error at the first time-step is (judging from your diagram) approx 10% and rapidly becoming smaller. Possible explanations are: the solution is not "totally correct" (try changing the tolerances of the linear solver and see if that error changes), error in the interpolation to the patches, time discretization: the summation at the patches is a pure explicit Euler while the other stuff depends on whatever scheme you chose for ddt

I am wondering how swak4foam and the libsimpleSwakFunctionObjects.so library compute exactly the integrals, I mean accuracy and method.

Thanks!
Best!

What do you mean? Usually integrals are implemented in the user expressions: size of the discretization elements (=cell volume or face area) times the (cell or face value). Sum.

__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request

A numer of questions:
- which OF-version
- which swak-version
- the fatal-error is without any context (so I could only guess what is going on). Try the following: "export FOAM_ABORT=1" and rerun. This should yield a stacktrace which would be helpful to see WHERE this is happening
- what is "expected results" and what are the results you get?

__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request

Now I have another problem... I know that to set a velocity ramp at the inlet one can do it by using both the uniformFixedValue function in OF and groovyBC. Well, I would like to set a ramp with the freestream BC and it's not possible to do it with 'uniformFixedValue', so is there any way to do it with groovyBC??