CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Problem with pos() or Scalar.H (http://www.cfd-online.com/Forums/openfoam/92792-problem-pos-scalar-h.html)

seboxx September 25, 2011 17:52

Problem with pos() or Scalar.H
 
Hi community,

I am trying to calculate the size of a wave segment.
Herefore I use
Code:

fvc::domainIntegrate(pos(u-1e-12))
u is my variable which is a volScalarField.

This is the error message I get
Quote:

In file included from fhnSolver.C:45:
/home/boie/OpenFOAM/OpenFOAM-reloaded/OpenFOAM-2.0.0/src/OpenFOAM/lnInclude/Scalar.H: In function 'int main(int, char**)':
/home/boie/OpenFOAM/OpenFOAM-reloaded/OpenFOAM-2.0.0/src/OpenFOAM/lnInclude/Scalar.H:38: error: expected primary-expression before 'template'
/home/boie/OpenFOAM/OpenFOAM-reloaded/OpenFOAM-2.0.0/src/OpenFOAM/lnInclude/Scalar.H:38: error: expected ';' before 'template'
/home/boie/OpenFOAM/OpenFOAM-reloaded/OpenFOAM-2.0.0/src/finiteVolume/lnInclude/initContinuityErrs.H:37: warning: unused variable 'cumulativeContErr'
fhnSolver.C:82: error: expected '}' at end of input
make: *** [Make/linuxGccDPOpt/fhnSolver.o] Error 1
This sounds like a problem in the Scalar.H header file. :confused:
But the Scalar.H file seems fine to me, is there any known problem with it?
I am using Scalar.H because pos() is declared in it.
Also I think the last error that } is missing is also related to that... cuz it disappears if I comment out the include Scalar.H

Is anyone able to make more sense of it?

I am happy about any suggestions. Thanks :)

l_r_mcglashan September 26, 2011 04:44

Works for me. Post up the simplest test case you have. What version of OF are you using?

seboxx September 26, 2011 05:03

1 Attachment(s)
Hi there,

I am using OF 2.0.0
I have had a look... even a Solver which is perfectly working doesnt compile anymore if I add the simple line
Code:

#include "Scalar.H"
without actually using one of its functions...
I have attached the file if you want to have a look at it...
I am really confused.

Thank you for your help.
Sebastian

l_r_mcglashan September 26, 2011 05:20

Ok, don't include Scalar.H, it will compile fine. Scalar.H contains template specialisations for type Scalar. If you're interested have a look at http://www.cantrip.org/traits.html.

seboxx September 26, 2011 07:07

Yea the compilation works.
But I have a problem which I had before. The pos(u-1e-12) gives me values either 0 or 1 depending whether u>1e-12.
Which is good :)

But by doing
Code:

double Size;
S=pos(u-1e-12);
Size = domainIntegrate(S).value()

I get a uniform value which is 90000 which doesnt depend on u at all.
I encountered this problem before, that's why i figured I might need Scalar.H for a proper pos() function.
My domain is a block of size 1000 * 1000 * 0.1
therefore the 90000 isnt even the size of my domain...
Any idea why I get this constant value?

l_r_mcglashan September 27, 2011 04:27

Well S will be a field of 1s and 0s. You're then integrating, which will mean you sum all the 1s multiplied by the size of the volume they are in.

Do it on a simpler field with a much smaller size that you know should give you a specific answer.

seboxx September 27, 2011 05:36

You are right. I got confused due to the complexity of my field. Thanks for the hints :)


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