# how to extract vector from tensor ?

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

 March 2, 2011, 14:01 how to extract vector from tensor ? #1 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 229 Rep Power: 9 Hi! I would like to extract a vector from a tensor. I know one can recover a scalar from a tensor using T.xx() ; T.xy() ... Do you know what can I do to recover the first column of my tensor ? Best, Cyp

 March 2, 2011, 16:11 #2 Senior Member   Steven van Haren Join Date: Aug 2010 Location: The Netherlands Posts: 149 Rep Power: 6 Take a look at this util: Cannot convert rms velocity fluctuations by foamToFieldview9 utility You should be able to edit this utility to output the first column of your tensor.

 March 2, 2011, 18:03 #3 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 229 Rep Power: 9 Hi Steve! Thank you for your answer. I had a look at your code. I tried this snippet : Code: ``` D1.component(tensor::XX) = U1x.component(vector::X); D1.component(tensor::YX) = U1x.component(vector::Y); D1.component(tensor::ZX) = U1x.component(vector::Z);``` It compiles but my tensor D1 is not update with the U1x values.. Do you why I am wrong ? Regards, Cyp

 March 3, 2011, 05:14 #4 Senior Member   Steven van Haren Join Date: Aug 2010 Location: The Netherlands Posts: 149 Rep Power: 6 Hard to say like this. Can you post the entire code?

 March 3, 2011, 06:25 #5 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 229 Rep Power: 9 Hi Steven! Actually, this the piece of code Code: ``` fvVectorMatrix U1xEqn ( fvm::ddt(U1x) - fvm::laplacian(nu, U1x) + unitE*alpha*vector(1,0,0) ); solve(U1xEqn == -fvc::grad(p1x)); // --- PISO loop for (int corr=0; corr

 March 3, 2011, 06:57 #6 Senior Member   Steven van Haren Join Date: Aug 2010 Location: The Netherlands Posts: 149 Rep Power: 6 like this it works: Code: `D1= tensor(1,0,0,0,0,0,0,0,0)*U1x.component(vector::X);` I know it looks a bit strange but at least it works

 March 3, 2011, 08:47 #7 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 229 Rep Power: 9 Thank you for your answer.. in fact, it not really worked since when you write : Code: ```D1= tensor(1,0,0,0,0,0,0,0,0)*U1x.component(vector::X); D1= tensor(0,0,0,1,0,0,0,0,0)*U1x.component(vector::Y);``` The first instruction is not accounted for... So, indeed I could do : Code: ```D1= tensor(1,0,0,0,0,0,0,0,0)*U1x.component(vector::X) + tensor(0,0,0,1,0,0,0,0,0)*U1x.component(vector::Y);``` but it's not what I looked for....

 Thread Tools Display Modes Linear Mode

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

 Similar Threads Thread Thread Starter Forum Replies Last Post duongquaphim OpenFOAM Programming & Development 0 January 10, 2011 14:51 Jason FLUENT 1 November 26, 2010 06:20 volker OpenFOAM Programming & Development 7 June 3, 2010 08:08 ZHANG Main CFD Forum 0 June 18, 2007 12:51 Chun Min Chew Main CFD Forum 3 December 10, 2003 12:34

All times are GMT -4. The time now is 09:49.