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

Obtaining velocity components

Register Blogs Community New Posts Updated Threads Search

Like Tree13Likes
  • 9 Post By kmurphy
  • 1 Post By luca_g
  • 1 Post By srinath
  • 1 Post By luca_g
  • 1 Post By linch

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 8, 2008, 03:03
Default Obtaining velocity components
  #1
Member
 
srinath
Join Date: Mar 2009
Location: Champaign, USA
Posts: 91
Rep Power: 17
srinath is on a distinguished road
Hello

This is rather trivial, but for some reason i can't seem to get this line to work.
volScalarField vx = U.x();
The compilation error i get is
error: 'struct Foam::volVectorField' has no member named 'x'

Could someone tell me the right way to get velocity components?

Thanks
Srinath
srinath is offline   Reply With Quote

Old   August 8, 2008, 10:49
Default Srinath, You could try
  #2
New Member
 
kmurphy
Join Date: Mar 2009
Posts: 10
Rep Power: 17
kmurphy is on a distinguished road
Srinath,

You could try

U.component(vector::X)

or

U.component(0)

Regards,
Kieran
kmurphy is offline   Reply With Quote

Old   August 9, 2008, 04:52
Default Hi, could I ask the way I set:
  #3
Senior Member
 
ZHOU Bin
Join Date: Mar 2009
Location: Nanjing/Torino, Nanjing/Piemente, China/Italy
Posts: 164
Rep Power: 17
zhoubinwx is on a distinguished road
Send a message via ICQ to zhoubinwx Send a message via MSN to zhoubinwx Send a message via Skype™ to zhoubinwx
Hi, could I ask the way I set: partial(Ux)/partial(x) is right?

grad(U.component(vector::X)).component(0)

Thanks

Bin
zhoubinwx is offline   Reply With Quote

Old   August 9, 2008, 06:10
Default Thanks Kieran That worked f
  #4
Member
 
srinath
Join Date: Mar 2009
Location: Champaign, USA
Posts: 91
Rep Power: 17
srinath is on a distinguished road
Thanks Kieran

That worked for the expression

vx= U.component(0)

But i get a runtime error if i do this

volVectorField newphiU = phiU
newphiU.componet(0) = f(scalars).

The error i get is
--> FOAM FATAL ERROR : attempted to assign to a const reference to constant object#0 Foam::error::printStack(Foam:stream&) in "/home/srinath/OpenFOAM/OpenFOAM-1.4.1/lib/linuxGccDPOpt/libOpenFOAM.so"
#1 Foam::error::abort() in "/home/srinath/OpenFOAM/OpenFOAM-1.4.1/lib/linuxGccDPOpt/libOpenFOAM.so"

Could someone tell me the 'correct way' to assign components of a volVector field?

Regards
Srinath
srinath is offline   Reply With Quote

Old   August 9, 2008, 06:44
Default Srinath, I believe that (in
  #5
Member
 
Luca Gasparini
Join Date: Mar 2009
Location: Italy
Posts: 37
Rep Power: 17
luca_g is on a distinguished road
Srinath,

I believe that (in most cases) you should be able to find a way to deal with vectors as a whole, and not with individual components. This will keep code more compact and readable.
Maybe it is worth trying.

Regards,
Luca
Kummi likes this.
luca_g is offline   Reply With Quote

Old   August 9, 2008, 07:37
Default Dear Luca Suppose i have a
  #6
Member
 
srinath
Join Date: Mar 2009
Location: Champaign, USA
Posts: 91
Rep Power: 17
srinath is on a distinguished road
Dear Luca

Suppose i have a matrix A times vector B
C= A*B
A is 5*5, B is 5*1
i want to group rhoU from the central 3 components
Any ideas?

Thanks
Srinath
srinath is offline   Reply With Quote

Old   August 9, 2008, 16:56
Default What do you mean by central co
  #7
nadine
Guest
 
Posts: n/a
What do you mean by central components? C_2,C_3 and C_4?

If yes:
rhoU=D*C where
D=[
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0].

If not, post the complete example code, because your questions hardly make sense.
  Reply With Quote

Old   August 10, 2008, 00:10
Default Nadine Since i didn't know
  #8
Member
 
srinath
Join Date: Mar 2009
Location: Champaign, USA
Posts: 91
Rep Power: 17
srinath is on a distinguished road
Nadine

Since i didn't know how to assemble a 5 component pseudoVector in OpenFoam, i explicitly carried out the multiplication A*B
Right now, i have C(1), C(2)....C(5).
If i could group these entries into a pseudovector C, i could do what u suggest.

I am trying to solve dw/dt + A\Sigma F.\Delta S = 0
\Sigma F\Delta S is computed previously and plays the role of B.
I know it's components B(1), [B(2), B(3),B(4)],B(5).

I have copied and pasted the relevant portion of the code with some comments

----------Here is B----------------------------
volScalarField res_rho = fvc::div(phi_rho);
volVectorField res_rhoU = fvc::div(phi_rhoU);
volScalarField res_rhoE = fvc::div(phi_rhoE);
------------------------------------------------
--------Entries of A are computed(I don't assemble them together as A---------------

-------I explicitly calculate C=A*B------------
volScalarField newphi_rho = .....ugly stuff....
volScalarField newphi_rhoU1 = ..........
volScalarField newphi_rhoU2 = ......
volScalarField newphi_rhoU3 = .......
volScalarField newphi_rhoE = ........
-------------------------------------------------
I don't know how to group the scalars newphi_* into a vector C to do rhoU = D*C

---I then proceed to say------------
solve(fvm::ddt(rho) == - newphi_rho)
solve(fvm::ddt(rhoU) == -newphi_rhoU)->Cant assemble from newphi_rhoU1 etc
solve(fvm::ddt(rhoE) == -newphi_rhoE

If this isn't clear i can mail you the code.
I tried pasting it, but i don't think it would be relevant to post 200 other lines doing other stuff in between.

Regards
Srinath
Kummi likes this.
srinath is offline   Reply With Quote

Old   August 10, 2008, 05:58
Default If you think your code is not
  #9
nadine
Guest
 
Posts: n/a
If you think your code is not relevant, then I think your question isn't either.

I don't want to make more guesses how your "volScalarField newphi_rho = .....ugly stuff...." looks in detail, if you provide information bit by bit. You could easily have attached the full 200 lines of code, while pointing out the relevant portions in the body of your post.

You could also put your problem in a more general context, so that somebody could recognize a problem that has a standard solution, but your

simply looks like an ordinary differential equation.

Good luck!
  Reply With Quote

Old   August 13, 2008, 01:29
Default Issue is resolved. Used the
  #10
Member
 
srinath
Join Date: Mar 2009
Location: Champaign, USA
Posts: 91
Rep Power: 17
srinath is on a distinguished road
Issue is resolved.
Used the following command to replace scalar fields in a volVectorField
newphi_rhoU.replace(0,newphi_rhoU1);

Srinath
srinath is offline   Reply With Quote

Old   August 18, 2008, 05:27
Default Srinath, I still suggest yo
  #11
Member
 
Luca Gasparini
Join Date: Mar 2009
Location: Italy
Posts: 37
Rep Power: 17
luca_g is on a distinguished road
Srinath,

I still suggest you that you don't need to explicitely use components.

For example:
vx*res_rhoU.component(0) + vy*res_rhoU.component(1) + vz*res_rhoU.component(2))
==> U & res_rhoU

Similarly you can formulate the three scalar equations for newphi_rhoU1, ..U2, ..U3 into a single vector equation for newphi_rhoU: just have a carefull look at them and collect all the terms appropriately. Than, it will look much nicer..

Regards,
Luca
Kummi likes this.
luca_g is offline   Reply With Quote

Old   January 16, 2009, 15:27
Default Hello All, A new question w
  #12
Senior Member
 
Mark Couwenberg
Join Date: Mar 2009
Location: Netherlands
Posts: 130
Rep Power: 17
markc is on a distinguished road
Hello All,

A new question which seems to fit here:

I want to combine 3 scalarFields into 1 vectorField:
>>>
scalarField Xdot(vectOmega & (pointCentres ^ vectX) );
scalarField Ydot(vectOmega & (pointCentres ^ vectY) );
scalarField Zdot(vectOmega & (pointCentres ^ vectZ) );
>>>
with:
vectX = (1,0,0), vectY=(0,1,0), vectZ=(0,0,1)
omega is a vector and pointCentres is a pointField defined as:
pointCentres = mesh.boundaryMesh()[patchI].localPoints();
<<<
Now I need a vectorField which looks likeXdot, Ydot, Zdot).

Any ideas how to accomplish this task? Does anyone see a possibility to define such a vectorField with one description, as Luca suggests?

Brgds,

Mark
markc is offline   Reply With Quote

Old   September 19, 2013, 11:08
Default
  #13
Senior Member
 
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 16
linch is on a distinguished road
Hi foamers,

does anyone know, how to overwrite a single component of a vector? For example: I have two dimensionedVectors V1 & V2 with same dimensions. And I want to set the Z-Component of the V2 to the Z-value of the V1. What i tried is:is:
Code:
V2.component(2) = V1.component(2);
and
Code:
V2.component(2).value() = V1.component(2).value();
, but the vector V2 doesn't change.

Best regards.
linch is offline   Reply With Quote

Old   September 19, 2013, 11:23
Default
  #14
Senior Member
 
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 16
linch is on a distinguished road
Solved:
Code:
V2.value().component(2) = V1.value().component(2);
mbookin likes this.
linch is offline   Reply With Quote

Old   October 20, 2014, 11:53
Default
  #15
New Member
 
Sandip Wadekar
Join Date: Oct 2014
Posts: 17
Rep Power: 11
wadekar is on a distinguished road
volScalarField U.x(1)
(
IOobject
(
"U.x(1)",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

I have tried this code for the velocity component, but i get the error-
ycleAvg.C:57:21: error: expected initializer before ‘.’ token
volScalarField U.x(1)
wadekar is offline   Reply With Quote

Old   July 30, 2015, 07:31
Default
  #16
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Quote:
Originally Posted by markc View Post
Hello All,

A new question which seems to fit here:

I want to combine 3 scalarFields into 1 vectorField:
>>>
scalarField Xdot(vectOmega & (pointCentres ^ vectX) );
scalarField Ydot(vectOmega & (pointCentres ^ vectY) );
scalarField Zdot(vectOmega & (pointCentres ^ vectZ) );
>>>
with:
vectX = (1,0,0), vectY=(0,1,0), vectZ=(0,0,1)
omega is a vector and pointCentres is a pointField defined as:
pointCentres = mesh.boundaryMesh()[patchI].localPoints();
<<<
Now I need a vectorField which looks likeXdot, Ydot, Zdot).

Any ideas how to accomplish this task? Does anyone see a possibility to define such a vectorField with one description, as Luca suggests?

Brgds,

Mark
Hi Mark,

Could you solve this problem? because I have a very similar problem like this.
I need to construct a volVectorField from three volScalarField, I have tried but got no success.

Thanks,
Syavash
syavash is offline   Reply With Quote

Old   March 27, 2021, 12:49
Default Velocity component in function objects
  #17
New Member
 
Mohsen Zarepour
Join Date: Feb 2021
Posts: 10
Rep Power: 5
moz455 is on a distinguished road
Hi,
Can anyone tell me how to write the velocity components of a phase in multiphase flow using function objects? I do not know what is the keyword for that.
moz455 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
What are the UVW velocity components Nikunj FLUENT 2 January 12, 2022 12:28
Velocity Components in foamDataToFluent flavio_pergolesi OpenFOAM Post-Processing 1 November 9, 2009 09:27
Obtaining Mean Velocity Sing FLUENT 2 January 27, 2007 08:28
How to specify velocity components in UDF Ynot FLUENT 1 March 11, 2006 13:53
Velocity components visualization Sileno Phoenics 1 September 28, 2005 12:06


All times are GMT -4. The time now is 08:12.