CFD Online Discussion Forums

CFD Online Discussion Forums (
-   STAR-CCM+ (
-   -   AbsoluteSize and GenericAbsoluteSize classes (

jfcorbett September 18, 2011 09:48

AbsoluteSize and GenericAbsoluteSize classes
What is the difference, if any, between the GenericAbsoluteSize and AbsoluteSize classes?

The STAR-CCM+ macro recorder always seems to cast AbsoluteSize to GenericAbsoluteSize before using it, for example:


GenericAbsoluteSize genericAbsoluteSize_1 = ((GenericAbsoluteSize) volumeSourceSize_0.getAbsoluteSize());

Do I absolutely have to cast the AbsoluteSize to a GenericAbsoluteSize like that? Or is it possible (as I hope it is) to shorten the code to:



abdul099 September 18, 2011 18:22

GenericAbsoluteSize extends AbsoluteSize. Therefore you should be able to get rid of the cast, as long as you don't use any method of GenericAbsoluteSize which isn't implemented in AbsoluteSize.
setValue() is implemented in AbsoluteSize and inherited to GenericAbsoluteSize, therefore it should be possible not to use the cast. At least I couldn't see anything in GenericAbsoluteSize which suggests, it wouldn't work.

But anyway you can be on the safe side and do it in one line even with the cast

((GenericAbsoluteSize) volumeSourceSize_0.getAbsoluteSize()).getValue().s etValue(value);

and it's not much more work.

jfcorbett September 21, 2011 07:19

Thanks abdul099. I also contacted CD-adapco support, and they basically confirmed what you said:


I just had a look on the Java API documentation of STAR-CCM+ and the GenericAbsoluteSize inherits all of its methods from the AbsoluteSize class, therefore you are correct you could use the shorter version that you mentioned. In fact I just tried this myself in a simple test case and it worked just fine.

I will ask the developers why the macro recorder always casts the AbsoluteSize to GenericAbsoluteSize, because it seems to me like this class is redundant. Perhaps there is something I am missing. I will let you know as soon as I hear back from them.

All times are GMT -4. The time now is 07:40.