|
[Sponsors] |
August 8, 2008, 04:03 |
Obtaining velocity components
|
#1 |
Member
srinath
Join Date: Mar 2009
Location: Champaign, USA
Posts: 91
Rep Power: 17 |
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 |
|
August 8, 2008, 11:49 |
Srinath,
You could try
|
#2 |
New Member
kmurphy
Join Date: Mar 2009
Posts: 10
Rep Power: 17 |
Srinath,
You could try U.component(vector::X) or U.component(0) Regards, Kieran |
|
August 9, 2008, 05:52 |
Hi, could I ask the way I set:
|
#3 |
Senior Member
|
Hi, could I ask the way I set: partial(Ux)/partial(x) is right?
grad(U.component(vector::X)).component(0) Thanks Bin |
|
August 9, 2008, 07:10 |
Thanks Kieran
That worked f
|
#4 |
Member
srinath
Join Date: Mar 2009
Location: Champaign, USA
Posts: 91
Rep Power: 17 |
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 |
|
August 9, 2008, 07:44 |
Srinath,
I believe that (in
|
#5 |
Member
Luca Gasparini
Join Date: Mar 2009
Location: Italy
Posts: 37
Rep Power: 17 |
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 |
|
August 9, 2008, 08:37 |
Dear Luca
Suppose i have a
|
#6 |
Member
srinath
Join Date: Mar 2009
Location: Champaign, USA
Posts: 91
Rep Power: 17 |
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 |
|
August 9, 2008, 17:56 |
What do you mean by central co
|
#7 |
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. |
|
August 10, 2008, 01:10 |
Nadine
Since i didn't know
|
#8 |
Member
srinath
Join Date: Mar 2009
Location: Champaign, USA
Posts: 91
Rep Power: 17 |
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 |
|
August 10, 2008, 06:58 |
If you think your code is not
|
#9 |
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! |
|
August 13, 2008, 02:29 |
Issue is resolved.
Used the
|
#10 |
Member
srinath
Join Date: Mar 2009
Location: Champaign, USA
Posts: 91
Rep Power: 17 |
Issue is resolved.
Used the following command to replace scalar fields in a volVectorField newphi_rhoU.replace(0,newphi_rhoU1); Srinath |
|
August 18, 2008, 06:27 |
Srinath,
I still suggest yo
|
#11 |
Member
Luca Gasparini
Join Date: Mar 2009
Location: Italy
Posts: 37
Rep Power: 17 |
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 |
|
January 16, 2009, 16:27 |
Hello All,
A new question w
|
#12 |
Senior Member
Mark Couwenberg
Join Date: Mar 2009
Location: Netherlands
Posts: 130
Rep Power: 17 |
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 |
|
September 19, 2013, 12:08 |
|
#13 |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 17 |
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); Code:
V2.component(2).value() = V1.component(2).value(); Best regards. |
|
September 19, 2013, 12:23 |
|
#14 |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 17 |
Solved:
Code:
V2.value().component(2) = V1.value().component(2); |
|
October 20, 2014, 12:53 |
|
#15 |
New Member
Sandip Wadekar
Join Date: Oct 2014
Posts: 17
Rep Power: 12 |
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) |
|
July 30, 2015, 08:31 |
|
#16 | |
Senior Member
Ehsan Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18 |
Quote:
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 |
||
March 27, 2021, 13:49 |
Velocity component in function objects
|
#17 |
New Member
Mohsen Zarepour
Join Date: Feb 2021
Posts: 10
Rep Power: 5 |
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. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
What are the UVW velocity components | Nikunj | FLUENT | 2 | January 12, 2022 13:28 |
Velocity Components in foamDataToFluent | flavio_pergolesi | OpenFOAM Post-Processing | 1 | November 9, 2009 10:27 |
Obtaining Mean Velocity | Sing | FLUENT | 2 | January 27, 2007 09:28 |
How to specify velocity components in UDF | Ynot | FLUENT | 1 | March 11, 2006 14:53 |
Velocity components visualization | Sileno | Phoenics | 1 | September 28, 2005 13:06 |