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

Extract Ux, Uy, Uz of U Field

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 8, 2020, 15:08
Default Extract Ux, Uy, Uz of U Field
  #1
New Member
 
Sebastian
Join Date: Apr 2019
Location: Germany
Posts: 12
Rep Power: 7
aeroBassti is on a distinguished road
Hello,

I'm Sebastian from Germany. I'm starting to write my one post-Pro-Solver. I modified a few other Solvers and wrote some post-Pro-Solvers with Vector-Field calculation. Now I need the Ux, Uy, Uz components for further calculation (radial velocity ,....). I know, that I could use postProcess, but that is not my aim. I found a few informations, but I'm not shure if they work with OF6.


My code (first try with Uz):


Code:
#include "fvCFD.H"   
#include "fvc.H"

int main(int argc, char *argv[])
{
  timeSelector::addOptions();
  #include "setRootCase.H"
  #include "createTime.H"
  #include "createMesh.H"
  instantList timeDirs = timeSelector::select0(runTime, args);

 double v=0; 
 forAll(mesh.C(),cell){v += mesh.V()[cell];}

  forAll(timeDirs, timeI)
  {
        runTime.setTime(timeDirs[timeI], timeI);
        mesh.readUpdate();

        Info << "Time = " << runTime.timeName() << endl;

    IOobject U
        (
            "U",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ
          );


    volScalarField Uz
    (
        IOobject
        (
            "Uz",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
    U.component(vector::Z)
      );                  

    Uz.write();

    }

    
    
Info << "Volumen:" << v <<  "m3" << endl;        
Info << "finished" << endl;    
    
    return 0;
}
I get the error message:


Code:
44:4: error: ‘class Foam::IOobject’ has no member named ‘component’
  U.component(vector::Z)
I hope you can help me or can give me a hint.


Best regards
aeroBassti is offline   Reply With Quote

Old   October 9, 2020, 03:04
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,686
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Looks like you might just want the components function object anyhow
https://www.openfoam.com/documentati...omponents.html
olesen is offline   Reply With Quote

Old   October 9, 2020, 05:36
Default
  #3
New Member
 
Sebastian
Join Date: Apr 2019
Location: Germany
Posts: 12
Rep Power: 7
aeroBassti is on a distinguished road
Sry, but that doesn't help me.


Do I forgot to include a file?
aeroBassti is offline   Reply With Quote

Old   October 9, 2020, 10:39
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,686
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by aeroBassti View Post
Sry, but that doesn't help me.


Do I forgot to include a file?

If you read your code more carefully, you notice that your U is an IOobject, not a volVectorField. Hard to get the component from that.
olesen is offline   Reply With Quote

Old   October 9, 2020, 11:06
Default
  #5
New Member
 
Sebastian
Join Date: Apr 2019
Location: Germany
Posts: 12
Rep Power: 7
aeroBassti is on a distinguished road
Thanks a lot. It works. Sometimes it is not easy to find such small mistakes.



I wish you a nice weekend.
aeroBassti is offline   Reply With Quote

Reply

Tags
components


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
funkySetBoundaryFields - Manipulation of existing field jhertel OpenFOAM Pre-Processing 16 May 18, 2020 06:32
field read after each Time Step johanning OpenFOAM Programming & Development 1 December 29, 2019 07:59
Access to field which is evaluated at the moment Tobi OpenFOAM Programming & Development 6 April 19, 2017 13:09
''unknown radialModelType type Gidaspow'' PROBLEM WITH THE BED TUTORIAL AndoniBM OpenFOAM Running, Solving & CFD 2 March 25, 2015 18:44
Extract velocity field in certain time step to MATLAB spatialtime CFX 3 September 9, 2009 18:30


All times are GMT -4. The time now is 07:33.