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

read volField from startTime or timeName directory

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 24, 2018, 05:27
Default read volField from startTime or timeName directory
  #1
Member
 
Karelke Yu
Join Date: Dec 2014
Posts: 96
Rep Power: 11
cfdopenfoam is on a distinguished road
Hi all,

I would like to in a post-processing tool read/construct a volScalarField using IOobject from whether the startTime directory or current time directory, depends on where the corresponding IO file exists. Could someone suggest an elegant way to do this?

Like:

Code:
autoPtr<volScalarField> pPtr
(
    IOobject
    (
        "p",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    ),
    mesh
);

if (pPtr.invalid())   // p-file may not exist in current time directory
{
pPtr.reset
(
    IOobject
    (
        "p",
        runTime.startTime(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    ),
    mesh
);
}
;

Not sure if it works. Any hints?
cfdopenfoam 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
Read Force Report by UDF denis.sanga@hotmail.it FLUENT 1 June 1, 2018 09:11
[mesh manipulation] Importing Multiple Meshes thomasnwalshiii OpenFOAM Meshing & Mesh Conversion 18 December 19, 2015 18:57
Parallel Error in ANSYS FLUENT 12 zeusxx FLUENT 25 July 17, 2015 04:40
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Meshing & Mesh Conversion 12 May 2, 2013 10:52
999999 (../../src/mpsystem.c@1123):mpt_read: failed:errno = 11 UDS_rambler FLUENT 2 November 22, 2011 09:46


All times are GMT -4. The time now is 20:04.