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

Operation to READ_IF_PRESENT field

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By niklas
  • 1 Post By niklas

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 17, 2009, 08:28
Default Operation to READ_IF_PRESENT field
  #1
Senior Member
 
sega's Avatar
 
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20
sega is on a distinguished road
Hello World.

What happens to an operation like
Code:
volVectorField us = fvc::interpolate(U)
done to to a field (U in this case) which is READ_IF_PRESENT?

Will this operation cause an error or will it just be skipped if the field is not present?!
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!"
sega is offline   Reply With Quote

Old   September 17, 2009, 09:17
Default
  #2
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
READ_IF_PRESENT just means that the field will be read from disk if it is available,
otherwise it will be set to the value given in the constructor.
niklas is offline   Reply With Quote

Old   February 12, 2011, 03:39
Default ....
  #3
Member
 
Mohammad.R.Shetab
Join Date: Jul 2010
Posts: 49
Rep Power: 15
mrshb4 is on a distinguished road
Hi
[READ_IF_PRESENT just means that the field will be read from disk if it is available,
otherwise it will be set to the value given in the constructor. ]
What do you mean the value given in the constructor?
mrshb4 is offline   Reply With Quote

Old   February 14, 2011, 02:14
Default
  #4
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
Code:
volScalarField hTotal
(
    IOobject
    (
        "hTotal",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT,
        IOobject::AUTO_WRITE
    ),
    h+h0
);
In the above example,
if the file hTotal exists, the value will be read from that file.
Otherwise it will use the values from 'h+h0'
rajibroy likes this.
niklas is offline   Reply With Quote

Old   February 14, 2011, 04:13
Default
  #5
Member
 
Mohammad.R.Shetab
Join Date: Jul 2010
Posts: 49
Rep Power: 15
mrshb4 is on a distinguished road
Hi Niklas
Thanks for your reply.
I have another problem, that by now I've couldn't solve that!
I'm solving an equiation with a source term, like:
ddt2(p)-laplacian(p)=q
(source term is q)
I calculate source term from another solver every 1e-5 second and bring all of them in time directories in this solver.
The time interval of this solver is 1e-8 and I want that this solver reads every q whenever it reachs its time. For example at first it reads q in 0 directory and work with that, but when it reachs 1e-5 q should be read and changed and so on.......

Do you know how should I define q to be read like this?!?

Thank you
Mohammadreza
mrshb4 is offline   Reply With Quote

Old   February 14, 2011, 04:27
Default
  #6
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
You read q at start so that volScalarField exists already, then you place the code below
just before the equation you want to solve

Code:
    IOobject qHeader
    (
        "q",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ
    );

    if (qHeader.headerOk())
    {    
        volScalarField qNew
       (
            IOobject
            (
                "q",
                runTime.timeName(),
                mesh,
                IOobject::MUST_READ,
                IOobject::NO_WRITE
            ),
            mesh
        );
        q = qNew;

    }
    // ... solve the equation with the new q
This will try and read a new field every time step, but it will only update it when it exists
Roozbeh_Sa likes this.
niklas is offline   Reply With Quote

Old   February 15, 2011, 09:57
Default
  #7
Member
 
Mohammad.R.Shetab
Join Date: Jul 2010
Posts: 49
Rep Power: 15
mrshb4 is on a distinguished road
Hi Niklas

Thank you so much for your reply...with a little modification it worked properly.

Mohammadreza
mrshb4 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
Phase Field modeling in OpenFOAM adona058 OpenFOAM Running, Solving & CFD 35 November 16, 2021 00:16
Adding Temperature field to IcoFoam yapalparvi OpenFOAM Programming & Development 14 November 19, 2015 04:57
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 06:51
Initial Condition in 3D flows. shekharc Main CFD Forum 9 June 8, 2005 04:17


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