CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   cast vector to Type (

jordi.muela May 31, 2012 03:42

cast vector to Type
Hi all,

I'm modifying a boundary condition and I need to know how to cast a vector to Type, which is the type that I need to assign... I'm going to try explain it better:

the original boundary condition has:


and I know that timeSeries_(this->db().time().timeOutputValue()) returns Type. So I made a new function:


template<class Type>
Type Foam::timeVaryingSocketValuePointPatchField<Type>::recvSocketPos()

and I change the original line for:


Ok, now inside my new function recvSocketPos() I know that the info that i must return is a vector with the postion of the boundary, for example:


vector pos(x, y, z);
but of course I can't compile with:


I must cast in some way the pos vector to another var like Type vectorType, cause if i put in my code:


Type vectorType;

It compiles, but I can't find the way to cast a type to another. I tried many ways, for example, I thought that vector was a derived class of Type, so I tested:


Type *pType;       
pType = new(vector);

which is the usual way that i use in C++ when I have to use a class but I can't know it before compilation, only in runtime.

So please!! What's the way in OpenFOAM?? What are the relation between Type and vector classes?? Aren't parent and child respectively?

Lot of thanks in advance!!

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