CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Pre-Processing (
-   -   Tensor operation scale (

maka August 22, 2007 11:49

In programmer's guide: c_i =
In programmer's guide:
c_i = scale(a, b) = (a1*b1, a2*b2, a3*b3)

I'm looking for a similar operation but with division operators.

scalediv(a, b) = (a1/b1, a2/b2, a3/b3). Is there a function to do that? or I have to write a one? I intend to use it on 2 volVectorFields Thanks.

Best regards,

hjasak August 22, 2007 11:57

I needed this in my developmen
I needed this in my development stuff a while back and it's been added to my development version. It's called invScale.

I would recommend thinking carefully if you really need it or not. If you do, you can grep and search because for proper functionality it needs to be added in 4-5 places.

Good luck,


paka August 22, 2007 14:21

I do not know how complicated
I do not know how complicated is your case, but can't you simply make d_i = 1/b_i and then a_i * d_i ?

maka August 23, 2007 05:41

Thanks Hrv, I will try it. @
Thanks Hrv, I will try it.
@Krystian: the operation of scalar division is defined as tensor/scalar but not the opposite. As a result 1/tensor will give a compilation error.

Best regards,

grtabor August 23, 2007 06:06

Which is exactly what it shoul
Which is exactly what it should do. What do you mean by 1/tensor? The operation is not mathematically defined. You could ask for the inverse of the tensor, of course, but is that what you mean?

For that matter, scaling one vector by another component-wise probably is mathematically a bit dodgy as well. If you are looking for a transformation of the vector by different amounts in each direction, once again this would be a tensor operation.


maka August 23, 2007 08:52

The operation of devision is n
The operation of devision is not defined for vector (example of a tensor) because it only has a meaning when they are parallel. But here what I'm after is not an legitimate operation on vector or tensor. I need a scaling FUNCTION, that can take on vector field and scale it by another vector field (element by element scalar division). Assume you have two terms in an equation and you explicitly want to see how they wait relative to each other during run time. Then you will not Hrv's invScale function. That was exactly my situation. Thanks Gavin and Krystian for your comments. Please feel free to criticize the need that I explained. At the moment, I'm recompiling after I added Hrv's function. Thanks for your help.

Best regards,

maka November 11, 2008 13:57

If we have an equation: s*T1=
If we have an equation:
s*T1=T2; where s is unknown scalar; T1 and T2 is two tensors; How can we calculate s by well defined mathematical operation?

s=T2/T1; is not mathematically defined. Thanks.

maka November 11, 2008 14:07

I think it should be: s*T1*
I think it should be:

s*T1*inv(T1)= s*I=T2*inv(T1);

Then we know X=s*I;
s=sqrt(mag(X)/n); where n is the number of diagonal elements of the tensor I;

is that correct? Thanks.

maka November 20, 2008 08:43

I think it is: s=tr(T2 & in
I think it is:

s=tr(T2 & inv(T1))/3;

mscheng September 11, 2012 02:36

where can I find invScale function?

sharonyue October 10, 2013 20:27

Anyone knows where can I find this scale function's header?

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