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

Operation to READ_IF_PRESENT field

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools 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: 11
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: 19
niklas 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, 04:39
Default ....
  #3
Member
 
Mohammad.R.Shetab
Join Date: Jul 2010
Posts: 49
Rep Power: 7
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, 03:14
Default
  #4
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 19
niklas 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'
niklas is offline   Reply With Quote

Old   February 14, 2011, 05:13
Default
  #5
Member
 
Mohammad.R.Shetab
Join Date: Jul 2010
Posts: 49
Rep Power: 7
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, 05:27
Default
  #6
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 19
niklas 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
niklas is offline   Reply With Quote

Old   February 15, 2011, 10:57
Default
  #7
Member
 
Mohammad.R.Shetab
Join Date: Jul 2010
Posts: 49
Rep Power: 7
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

Thread Tools
Display Modes

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 On
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 24 January 31, 2015 07:01
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
Adding Temperature field to IcoFoam yapalparvi OpenFOAM Running, Solving & CFD 13 January 18, 2014 09:25
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07: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 15:04.