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

How to solve this

Register Blogs Community New Posts Updated Threads Search

Rate this Entry

How to solve this

Posted February 23, 2017 at 04:20 by kindle

Quote:
Originally Posted by dbxmcf View Post
Hi, all:

I intended to specify a volScalarField p with boundaryField and internal Field specified by another function call instead of read from case file on hard drive, e.g. cavity/0/p, and in the creatFields.H for icoFoam.C I found the p was constructed using the following:
//-------------------------------------
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

I tried change the readoption IOobject::MUST_READ to IOobject::NO_READ, it compiles but then when the program runs I got:

--> FOAM FATAL IO ERROR : NO_READ specified for read-constructor

After searching the Doxygen and read the source file of GeometryField.C it seems that the createFields.H file of icoFoam.C used a constructor that will create a read-only volScalarField, I am not sure if there is some example to create such kind of volScalarField p that does not necessarily have to initiate from the disk file? I tried to use the IOobject::READ_IF_PRESENT, but the compiled program still tried to read from file and gave me an fatal error:

--> FOAM FATAL IO ERROR : cannot open file

file: /.../OpenFOAM/foamCases/run/cavity/p/0 at line 0.

Function: regIOobject::readStream(const word&)
in file: db/regIOobject/regIOobjectRead.C at line: 68.

FOAM exiting

I guess I need to use other constructor for class GeometricField but there are so many of them (totally 12 constructors) and it seems difficult for me to figure out how to use each of these? I searched the forum with the keyword "NO_READ", although this topic has been discussed for several times, I didn't find a satisfactory answer.

And kind of help is welcome!
Thanks a lot!
ssssssssssssssssssssssssssssssssssssssssssssssss
Posted in programming
Views 976 Comments 0 Edit Tags Email Blog Entry
« Prev     Main     Next »
Total Comments 0

Comments

 

All times are GMT -4. The time now is 00:53.