CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   cannot convert DataEntry to scalar (https://www.cfd-online.com/Forums/openfoam-programming-development/174892-cannot-convert-dataentry-scalar.html)

anishtain4 July 20, 2016 13:10

cannot convert DataEntry to scalar
 
Hi,

I'm trying to modify a boundary condition, so I've started off with oscillatingFixedValue. I wanted this new boundary condition to be only for velocity so I've changed/removed all the template<class Type>. Now when I try to compile, it complains:
Quote:

error: cannot convert ‘const Foam::autoPtr<Foam::DataEntry<double> >’ to ‘Foam::scalar {aka double}’ in return
error: invalid initialization of reference of type ‘Foam::scalar& {aka double&}’ from expression of type ‘Foam::autoPtr<Foam::DataEntry<double> >’
If I remove DataEntry part first error goes away but the second one sticks. Since I haven't touched this part I don't understand what is going wrong? Also I prefer to keep the DataEntry in my code.

hk318i July 21, 2016 02:11

Because it is a template class and you basically need a special instance (vector), you have to replace Type by vector.

jherb July 21, 2016 07:08

Have a look at the fixedNormalInletOutletVelocityFvPatchVectorField class. This might be a good starting point (if you want to specify the same velocity for all faces of your boundary patch).

anishtain4 July 21, 2016 13:30

Hassan: it is by default scalar not vector, (the same thing in the original boundary condition) hence the error <double>.

@Joachim: OscillatingFixedValue works fine for me, it's the autoPtr<DataEntry<scalar>> part that I haven't touched and complains after changes in non-related parts!!!!

I solved the issue by commenting the member functions as the ->value() of the DataEntry part would've done the same thing.

hk318i July 22, 2016 04:32

I did not mean in DataEntry. In your first post you said that your removed template<class Type> which mean you have to modify the entire class. Maybe I am not clear about your modifications.

anishtain4 July 22, 2016 09:45

Yep you're right, but the DataEntry part is not using template Type before I remove the template part. It's autoPtr<DataEntry<scalar>> from the very beginning, so I haven't touched it at all.

hk318i July 22, 2016 10:44

It is an interesting issue which may requires more investigation. I tried to reduce the template class to normal class and I get the same error. Actually this error make scene from the compiler point of view because ``frequency_`` for example is not scalar. Therefore the compiler complain about the return data type. For now, you can just remove these four function causing the error (if you don't need them) or change the return type. Also, you may consider using the template class as it is.

anishtain4 July 25, 2016 11:20

Yes that's what I did, commenting those lines.
But there's a new issue after that which I've been struggling. I'll make a new topic since it's a different issue.
Thanks for following up.


All times are GMT -4. The time now is 21:14.