|
[Sponsors] |
|
March 2, 2011, 13:01 |
how to extract vector from tensor ?
|
#1 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
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, 15:11 |
|
#2 |
Senior Member
Steven van Haren
Join Date: Aug 2010
Location: The Netherlands
Posts: 149
Rep Power: 15 |
Take a look at this util:
http://www.cfd-online.com/Forums/ope...9-utility.html You should be able to edit this utility to output the first column of your tensor. |
|
March 2, 2011, 17:03 |
|
#3 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
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); Regards, Cyp |
|
March 3, 2011, 04:14 |
|
#4 |
Senior Member
Steven van Haren
Join Date: Aug 2010
Location: The Netherlands
Posts: 149
Rep Power: 15 |
Hard to say like this.
Can you post the entire code? |
|
March 3, 2011, 05:25 |
|
#5 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
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<nCorr; corr++) { volScalarField rU1xA = 1.0/U1xEqn.A(); // rUA = 1.0/UEqn.A(); U1x = rU1xA*U1xEqn.H(); phi_1x = (fvc::interpolate(U1x) & mesh.Sf()) + fvc::ddtPhiCorr(rU1xA, U1x, phi_1x); adjustPhi(phi_1x, U1x, p1x); for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix p1xEqn ( fvm::laplacian(rU1xA, p1x) == fvc::div(phi_1x) ); p1xEqn.setReference(pRefCell, pRefValue); p1xEqn.solve(); if (nonOrth == nNonOrthCorr) { phi_1x -= p1xEqn.flux(); } } #include "continuityErrs.H" U1x -= rU1xA*fvc::grad(p1x); U1x.correctBoundaryConditions(); } D1.component(tensor::XX) = U1x.component(vector::X); D1.component(tensor::YX) = U1x.component(vector::Y); D1.component(tensor::ZX) = U1x.component(vector::Z); Code:
volTensorField D1 ( IOobject ( "D1", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedTensor("D1",dimensionSet(0,2,0,0,0),tensor::zero) ); |
|
March 3, 2011, 05:57 |
|
#6 |
Senior Member
Steven van Haren
Join Date: Aug 2010
Location: The Netherlands
Posts: 149
Rep Power: 15 |
like this it works:
Code:
D1= tensor(1,0,0,0,0,0,0,0,0)*U1x.component(vector::X); |
|
March 3, 2011, 07:47 |
|
#7 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
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); 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); |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
extract information from sample during simulation for use | duongquaphim | OpenFOAM Programming & Development | 0 | January 10, 2011 13:51 |
How to modify the stress tensor of momentum eqns. | Jason | FLUENT | 1 | November 26, 2010 05:20 |
curvature correction term, material derivative of a tensor | volker | OpenFOAM Programming & Development | 7 | June 3, 2010 08:08 |
About deformation gradient tensor | ZHANG | Main CFD Forum | 0 | June 18, 2007 12:51 |
second invariant of rate-of-strain tensor | Chun Min Chew | Main CFD Forum | 3 | December 10, 2003 11:34 |