How to sum up a volScalarField
Dear Foamers,
i build a small postprocessing program, which calculates the volume of each cell and multiplies it by the a concentration of this cell. (It is a case, where I simulate the drug-transport through a coronary artery). So I know about the mass of drug in each cell, but i would like to sum all values up, so that I get the overall value... Does anyone have a clue, how to do this? Thank you very much Regards, Martin |
You can simply use
Code:
scalar sum = gSum(C); Cheers, Lieven |
Dear Lieven,
thank you very much for your answer. Unfortunately wmake gives out the following errors: wirkstoffgehalt.C: In function ‘int main(int, char**)’: wirkstoffgehalt.C:158: error: ‘sum’ cannot be used as a function wirkstoffgehalt.C:141: warning: unused variable ‘Gesamtwirkstoffgehalt’ make: *** [Make/linux64GccDPOpt/wirkstoffgehalt.o] Fehler 1 I added this line at the end of my program.C - Code, which now looks as follows: Code:
/*---------------------------------------------------------------------------*\ Regards, Martin |
Ok, but you should copy the code a bit more carefully (it is gSum and not simply sum) and it is also bit tricky what you try to do in your code.
You try to create a variable with the same name as the function you are calling. I'm certainly not an C++ experiment but I can imagine that could cause problems... Cheers, L |
Hey Lieven,
I tried another way. The program from above gives out a volScalarField (let's call it "Values") with another program, I read in Values, and tried your "gsum" lines again, but it did nor work. # gsum is not defined in this scope Is a header missing? Regards, Martin Code:
/*---------------------------------------------------------------------------*\ |
gSum!=gsum
|
Dear Leaven and Lin,
thank you very much for your help! It was a spelling problem of mine. Now it works fine :) |
All times are GMT -4. The time now is 14:02. |