CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

cast vector to Type

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 31, 2012, 04:42
Default cast vector to Type
  #1
New Member
 
Jordi Muela
Join Date: Mar 2011
Posts: 27
Rep Power: 16
jordi.muela is on a distinguished road
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!!
jordi.muela is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
singularity? mihaipruna OpenFOAM Running, Solving & CFD 5 April 24, 2012 18:18
Pressure instability with rhoSimpleFoam daniel_mills OpenFOAM Running, Solving & CFD 44 February 17, 2011 18:08
latest OpenFOAM-1.6.x from git failed to compile phsieh2005 OpenFOAM Bugs 25 February 9, 2010 05:37
Compilation errors in ThirdPartymallochoard feng_w OpenFOAM Installation 1 January 25, 2009 07:59
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 21:50


All times are GMT -4. The time now is 18:42.