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

How to write fluctuating velocity field at runtime?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 22, 2014, 09:53
Default How to write fluctuating velocity field at runtime?
  #1
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 13
huangxianbei is on a distinguished road
Hi,all
I'm doing a LES simulation. And I want to write the fluctuating velocity, that is:
u'=U-UMean, so how can I implement this? I tried like this
Code:
Info<< "Reading field UMean\n" << endl;
    volVectorField UMean
    (
        IOobject
        (
            "UMean",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ

        ),
        mesh
    );
    volVectorField Ufluc
    (
        IOobject
        (
            "Ufluc",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );
    Ufluc=U-UMean;
    Ufluc.write();
However, when calculate, error occurs
Code:
NO_READ specified for read-constructor of object Ufluc of class IOobject

    From function regIOobject::readStream()
    in file db/regIOobject/regIOobjectRead.C at line 46.

FOAM aborting
can anyone help?
huangxianbei is offline   Reply With Quote

Old   April 22, 2014, 10:10
Default
  #2
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 13
huangxianbei is on a distinguished road
The innovation to do this is to define the fluctuating field as to do post-process about u', although I know it's possible to do U-UMean in post-process, I still want to know if this can be accomplished directly.
huangxianbei is offline   Reply With Quote

Old   April 27, 2014, 10:10
Default
  #3
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21
tomislav_maric is on a distinguished road
You have specified the the Ufluc field not to be read from a file, and have failed to provide initial values that are in that case required to construct the field:

Code:
volVectorField Ufluc 
(         
    IOobject 
    ( 
        "Ufluc", 
        runTime.timeName(),             
        mesh, 
        IOobject::NO_READ,
        IOobject::AUTO_WRITE 
    ),         
    mesh // Missing initial values
);
If you don't want to provide the field in the '0' directory as a file to be read at run-time, you have to provide the default initialization argument:

Code:
volVectorField Ufluc    
(         
     IOobject         
     (             
         "Ufluc",            
         runTime.timeName(),             
         mesh,             
           IOobject::NO_READ,             
         IOobject::AUTO_WRITE         
     ),         
     mesh, 
       dimensionedVector
      (
           "zero", 
           U.dimensions(), // Or Umean.dimensions()
           vector (0,0,0)
      )
 );
Also, don't use the 'regIOobject::write()' inherited member function of a field to do the writing - this will write the field every time step and will probably mess up the case. Writing should be taken care of by the 'Time' class, with:

Code:
runTime.write();
This way it won't happen for example that you output 'Ufluc' every time step, and 'U' and 'Umean' every 10th time step.
__________________
When asking a question, prepare a SSCCE.

Last edited by tomislav_maric; April 27, 2014 at 10:14. Reason: code formatting was messed up
tomislav_maric is offline   Reply With Quote

Old   April 28, 2014, 07:14
Default
  #4
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 13
huangxianbei is on a distinguished road
Quote:
Originally Posted by tomislav_maric View Post
You have specified the the Ufluc field not to be read from a file, and have failed to provide initial values that are in that case required to construct the field:

Code:
volVectorField Ufluc 
(         
    IOobject 
    ( 
        "Ufluc", 
        runTime.timeName(),             
        mesh, 
        IOobject::NO_READ,
        IOobject::AUTO_WRITE 
    ),         
    mesh // Missing initial values
);
If you don't want to provide the field in the '0' directory as a file to be read at run-time, you have to provide the default initialization argument:

Code:
volVectorField Ufluc    
(         
     IOobject         
     (             
         "Ufluc",            
         runTime.timeName(),             
         mesh,             
           IOobject::NO_READ,             
         IOobject::AUTO_WRITE         
     ),         
     mesh, 
       dimensionedVector
      (
           "zero", 
           U.dimensions(), // Or Umean.dimensions()
           vector (0,0,0)
      )
 );
Also, don't use the 'regIOobject::write()' inherited member function of a field to do the writing - this will write the field every time step and will probably mess up the case. Writing should be taken care of by the 'Time' class, with:

Code:
runTime.write();
This way it won't happen for example that you output 'Ufluc' every time step, and 'U' and 'Umean' every 10th time step.
Hi,Tomislav:
Thank you for your reply. Where should I put the 'runTime.write()' as you say? .H file or in the .C file?
huangxianbei is offline   Reply With Quote

Old   April 29, 2014, 04:41
Default
  #5
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21
tomislav_maric is on a distinguished road
[QUOTE]
Thank you for your reply. Where should I put the 'runTime.write()' as you say? .H file or in the .C file?
[\QUOTE]

'runTime' is a global object (class 'Foam::Time'), and it's usually used in application (solver) client code - if you open a solver you are interested in, you will find it at the end of the main simulation loop.

If you are doing modifications in createFields.H, you don't have to explicitly write the fields there with '.write()', the solver will take care of the writing of all registered fields.
__________________
When asking a question, prepare a SSCCE.
tomislav_maric is offline   Reply With Quote

Old   April 29, 2014, 21:41
Default
  #6
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 13
huangxianbei is on a distinguished road
[QUOTE=tomislav_maric;488832]
Quote:
Thank you for your reply. Where should I put the 'runTime.write()' as you say? .H file or in the .C file?
[\QUOTE]

'runTime' is a global object (class 'Foam::Time'), and it's usually used in application (solver) client code - if you open a solver you are interested in, you will find it at the end of the main simulation loop.

If you are doing modifications in createFields.H, you don't have to explicitly write the fields there with '.write()', the solver will take care of the writing of all registered fields.
Oh,that's to say, I don't need to do with the '.write' since the solver has already done this. The only thing is to create the filed I need.
huangxianbei is offline   Reply With Quote

Reply


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
A Question About Setting Whole Velocity Field Using "Proflie" in FLUENT adsl17754 FLUENT 5 July 31, 2018 04:29
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
Setting the Velocity Field Adammann OpenFOAM 1 July 8, 2011 02:15
transient temperature field with constant velocity Törnquist CFX 0 September 16, 2003 04:22
Pressure from velocity field Svante Hellzén Main CFD Forum 5 November 30, 1999 18:20


All times are GMT -4. The time now is 01:35.