CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   scale(a, b) function (https://www.cfd-online.com/Forums/openfoam-programming-development/79685-scale-b-function.html)

 ozgur August 31, 2010 09:05

use of scale(a, b) function?? error: ‘scale’ was not declared in this scope

Hi,

In the Programmer’s Guide there is a description of a function named as scale:

Quote:
 As the name suggests, the scale function is a tool for scaling the components of one tensor by the components of another tensor of the same rank. It is evaluated as the product of corresponding components of 2 tensors, e.g., scaling vector a by vector b would produce vector c whose components are ci = scale(a, b) = (a1b1, a2b2, a3b3)
I have tried to use it however, I get the following error during compilation:
Code:

`error: ‘scale’ was not declared in this scope`
My code is simple:

Code:

```#include "fvCFD.H" ... vector a(1,2,3), b(4,5,6), c; c=scale(a,b)```

What can I do about this?

Thanks,

Ozgur

 ngj August 31, 2010 11:25

Unfortunately the Programmers Guide is not up to date, as the function is now called "cmptMultiply".

Best regards,

Niels

 ozgur September 1, 2010 05:53

Hi Niels,

Thanks again :)

Ozgur

 sunliming December 31, 2012 02:02

Can cmptMultiply be used for scalarField, e.g. cmptMultiply(points1,points2) where type of points1 and points2 is scalarField?

 ngj December 31, 2012 10:19

Hi Nick,

You can just multiply two scalarFields with the operator "*", which result in a scalarField, so the cmptMultiply is not needed.

Happy New Year

Niels

 sunliming January 1, 2013 03:11

Hi Niels,
Thank you! It's cool and convenient to use "*" for scalarField multiply. Sometimes it is just hard to access OpenFOAM for there are so few documents about how to operate field. And it's slow and inefficient to dig in the source code itself. If there are some instructions of handing fields, that would be better for OpenFAOM user programming!

Happy new year!
Nick

 yvesc May 26, 2014 19:34

Thank you Niels

Quote:
 Originally Posted by ngj (Post 273505) Unfortunately the Programmers Guide is not up to date, as the function is now called "cmptMultiply". Best regards, Niels
*sigh* this is 2013, and the Programmer's Guide is still not up-to-date.
Lost me 1/2 hour.

 pfontana August 27, 2015 17:02

How do you multiply a vector field by a scalar constant? If alpha is a const and U is a vector field (e.g. velocity), is it just cmptMultiply(U,alpha) or cmptMultiply(alpha,U)? (I tried just using a * U, but I got a compile-time error. The file createFields.H defines alpha as follows:

Quote:
 Info<< "Reading transportProperties\n" << endl; IOdictionary transportProperties ( IOobject ( "transportProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ); dimensionedScalar alpha ( transportProperties.lookup("alpha") );
and the file transportProperties contains an entry for alpha (even though that shouldn't matter for compilation??):
Quote:
 alpha alpha [ 0 0 -1 0 0 0 0 ] 7.0;
)

The compile-time error I get is
Quote:
 fatal error: error in backend: IO failure on output stream.

 All times are GMT -4. The time now is 18:24.