|
[Sponsors] |
March 15, 2022, 15:07 |
reference to a velocity component
|
#1 |
New Member
Join Date: Feb 2022
Posts: 25
Rep Power: 4 |
Hello to all,
I would like to know if it is possible to get a reference to a component of the velocity. Code:
volVectorField U ( IOobject ( "U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); Code:
scalarField& Ux = U.component(0) // This does not appear to work |
|
March 16, 2022, 11:59 |
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
If you take U.component(vector::X), you are extracting a tmp field, cannot bind this to a reference!
Code:
tmp<scalarField> tcompx = U.component(vector::X); // OR scalarField tcompx(U.component(vector::X)); You need to think about how the data is stored. The vector field (U) is a array of structs x/y/z. But you wish to have something like a struct of arrays, which is not there. If you want to be memory efficient, you can loop over the velocity field and return the x() component of the individual velocity entry. This will be memory efficient. Not sure if it fits nicely into your code though. |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Setting the height of the stream in the free channel | kevinmccartin | CFX | 12 | October 13, 2022 22:43 |
Compression stoke is giving higher pressure than calculated | nickjuana | CFX | 62 | May 19, 2015 14:32 |
OF211: ThirdParty and /src compiled, but not /applications... | vkrastev | OpenFOAM Installation | 8 | October 18, 2012 16:53 |
error message | cuteapathy | CFX | 14 | March 20, 2012 07:45 |
Windows Installation BugsComments on Petrbs patch | brooksmoses | OpenFOAM Installation | 48 | April 16, 2006 01:20 |