CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

Vector field from scalars

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   May 11, 2010, 10:39
Default Vector field from scalars
  #1
New Member
 
Vadims Geza
Join Date: Apr 2010
Location: Latvia
Posts: 9
Rep Power: 7
Vadims.geza is on a distinguished road
Hello all!

I need to create vector field from three scalars. It can not be done by using vector operations in this case. I have got all scalar components VsX, VsY and VsZ.

volVectorField Vs
IOobject
(
"Vs",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
mesh,
dimenstionedVector("variableName", dimensionSet(0,0,0,0,0,0,0), Foam::vector(VsX,VsY,VsZ))

it says
error: no matching function for call to 'Foam::Vector<double>::Vector(Foam::volScalarField &, Foam::volScalarField&, Foam::volScalarField&)'

So, please give me some advice how to do this, if it is possible!
Many thanks in advance!
Vadims.geza is offline   Reply With Quote

Old   May 11, 2010, 13:51
Default
  #2
New Member
 
Valerio Novaresio
Join Date: Mar 2009
Location: Polonghera, Cuneo, Italy
Posts: 27
Rep Power: 8
novyno is on a distinguished road
Hi,

you can read the vectorField initialized with dummy values (i.e zero value):

volVectorField Vs
(
IOobject
(
"Vs",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

do the same with the scalarField(s):

volScalarField VsX
(
IOobject
(
"VsX",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

etc...

and finanlly:

forAll( Vs.internalField(), i)
{
Vs.internalField()[i].component(vector::X) = Vsx.internalField()[i];
Vs.internalField()[i].component(vector::Y) = Vsy.internalField()[i];
Vs.internalField()[i].component(vector::Z) = Vsz.internalField()[i];
}
forAll( Vs.boundaryField(), boundaryI)
{
forAll( Vs.boundaryField()[boundaryI], i)
{
Vs.boundaryField()[boundaryI][i].component(vector::X) = Vsx.boundaryField()[boundaryI][i];
Vs.boundaryField()[boundaryI][i].component(vector::Y) = Vsy.boundaryField()[boundaryI][i];
Vs.boundaryField()[boundaryI][i].component(vector::Z) = Vsz.boundaryField()[boundaryI][i];
}
}

Of course if you already have the fields you don't have to read them! :-)
__________________
...The best way to acquire new knowledge is to share it...
novyno is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
generic scalars in star manuutin STAR-CD 0 August 7, 2009 06:05
Passive scalars and Star-CCM+ Tim CD-adapco 1 May 19, 2008 11:04
Flux functions for User-Defined Scalars Zhengcai Ye FLUENT 0 October 8, 2004 10:34
about .run file and information of scalars isidro CD-adapco 0 March 11, 2004 12:37
The Field Scalars in Tascflow Darcy CFX 0 November 19, 2003 23:14


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