CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Boolean function to mimic basic Octave function (http://www.cfd-online.com/Forums/openfoam-programming-development/122978-boolean-function-mimic-basic-octave-function.html)

antoniofct September 2, 2013 07:22

Boolean function to mimic basic Octave function
 
Hi all,

I am trying to do some simple thing that takes no more than 15 seconds to do in Octave but it is taking me some hours in c++.

Regarding dynamic mesh, when selecting points to move, there is already a function in OF that picks the boundary points and everything goes well.

It happens that I just want some of the boundary points to move..so I would like to get something like this:

I have a pointField XYZ;

I would like to compare the pointField.component(0) with a scalar 0 (or a scalarFeld e.g. pointField.component(0) > 0) and return a scalarField with 1 if it is true and 0 if it is false.

I have tried something like this:

scalarField test = bool ( pointField.component(0) > vector::zero.component(0));

but it tells me I can't use the > operator..

I could get a similar result with a loop, but I am trying to avoid it..

any hints?

Thank you

António

akidess September 2, 2013 09:23

Something along the lines of:

scalarField test = pos ( pointField.component(0) - vector::zero.component(0) > 0);

antoniofct September 2, 2013 11:49

thanks, that was it!


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