CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   STAR-CCM+ (https://www.cfd-online.com/Forums/star-ccm/)
-   -   Field Function (https://www.cfd-online.com/Forums/star-ccm/144680-field-function.html)

Dgrimbs November 19, 2014 06:09

Field Function
 
hey,

I have problems with my Field Function. I would like to simulate movement and move the object in the Z-axis (dependent on time).
the equation of motion I have already written, but I have a problem that does not move the object in the negative direction of the coordinate system.

I hope someone of you can help me further.

Here is the definition of Field Function:

[($ Time <0.4)? 10 : (($ time>= 1.3) && ($ Time <1.7))? - 10: 0,0,0]

olesen November 20, 2014 03:03

Quote:

Originally Posted by Dgrimbs (Post 519952)
hey,

I have problems with my Field Function. I would like to simulate movement and move the object in the Z-axis (dependent on time).
the equation of motion I have already written, but I have a problem that does not move the object in the negative direction of the coordinate system.

I hope someone of you can help me further.

Here is the definition of Field Function:

[($ Time <0.4)? 10 : (($ time>= 1.3) && ($ Time <1.7))? - 10: 0,0,0]

I cannot promise that it will help, but I would really split this into two definitions to make sure that the parser works okay, especially with the ternary operation in there. It might also make your code easier to understand and maintain.

The position
Code:

MyPosition = ($Time < 0.4) ? 10 : (($Time >= 1.3 && $Time < 1.7) ? -10 : 0)
and then use
Code:

[${MyPosition}, 0, 0]
Note that you must also ensure that third element of the ternary is bracketed. This is not needed for C/C++/Java etc, but does seem to be needed for STARCCM.

Valid for STARCCM (and C/C++/Java etc)
Code:

conditon1 ? val1 : (condition2 ? val2 : val3)
Valid for C/C++/Java etc, but invalid for STARCCM
Code:

conditon1 ? val1 : condition2 ? val2 : val3


All times are GMT -4. The time now is 20:17.