|
[Sponsors] |
September 17, 2009, 09:28 |
Operation to READ_IF_PRESENT field
|
#1 |
Senior Member
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20 |
Hello World.
What happens to an operation like Code:
volVectorField us = fvc::interpolate(U) 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!" |
|
September 17, 2009, 10:17 |
|
#2 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
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. |
|
February 12, 2011, 04:39 |
....
|
#3 |
Member
Mohammad.R.Shetab
Join Date: Jul 2010
Posts: 49
Rep Power: 16 |
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? |
|
February 14, 2011, 03:14 |
|
#4 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
Code:
volScalarField hTotal ( IOobject ( "hTotal", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), h+h0 ); if the file hTotal exists, the value will be read from that file. Otherwise it will use the values from 'h+h0' |
|
February 14, 2011, 05:13 |
|
#5 |
Member
Mohammad.R.Shetab
Join Date: Jul 2010
Posts: 49
Rep Power: 16 |
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 |
|
February 14, 2011, 05:27 |
|
#6 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
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 |
|
February 15, 2011, 10:57 |
|
#7 |
Member
Mohammad.R.Shetab
Join Date: Jul 2010
Posts: 49
Rep Power: 16 |
Hi Niklas
Thank you so much for your reply...with a little modification it worked properly. Mohammadreza |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Phase Field modeling in OpenFOAM | adona058 | OpenFOAM Running, Solving & CFD | 35 | November 16, 2021 01:16 |
Adding Temperature field to IcoFoam | yapalparvi | OpenFOAM Programming & Development | 14 | November 19, 2015 05:57 |
Moving mesh | Niklas Wikstrom (Wikstrom) | OpenFOAM Running, Solving & CFD | 122 | June 15, 2014 07:20 |
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 05:17 |