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/)
-   -   cast vector to Type (http://www.cfd-online.com/Forums/openfoam-programming-development/102664-cast-vector-type.html)

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:

Code:

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

Code:

template<class Type>
Type Foam::timeVaryingSocketValuePointPatchField<Type>::recvSocketPos()
{
.....
}

and I change the original line for:

Code:

this->operator==(recvSocketPos());
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:

Code:

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

Code:

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

Code:

Type vectorType;
return(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:

Code:

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 10:29.