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

NO_READ specified for read-constructor

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 3, 2014, 00:43
Default NO_READ specified for read-constructor
  #1
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 848
Rep Power: 18
sharonyue is on a distinguished road
Hi guys,

There is someth wrong upon this constructor:
Code:
volScalarField K
    (
        IOobject
        (
            "K",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
        0.75*Cds*phase2->rho()*magUr*bp/d1
    );
The solver can be compiled with no error. but when it runs:
Code:
NO_READ specified for read-constructor of object n of class IOobject
More speciafically, Cds and magUr is:
Code:
volScalarField Cds
    (
        neg(Re - 1000)*(24.0*(1.0 + 0.15*pow(Re, 0.687))/Re)
      + pos(Re - 1000)*0.44
    );

dimensionedScalar rho_;

volVectorField Ur(U1 - U2);
volScalarField magUr(mag(Ur));

volScalarField bp(pow(Alpha2, -2.65));

volScalarField d1
    (
        IOobject
        (
            "d1",
            mesh.time().timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
     );
I dont know what happened, Thanks.

PS.
Even I change k to be:
Code:
volScalarField K
    (
        IOobject
        (
            "K",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
        d1
    );
The same error
sharonyue is offline   Reply With Quote

Old   April 3, 2014, 06:42
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22
Bernhard is on a distinguished road
How do you know the problem is in the definition of "K"? I do not see that from your error message. Are you sure it compiles without warnings? (run wclean first)
Bernhard is offline   Reply With Quote

Old   April 3, 2014, 09:26
Default
  #3
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21
tomislav_maric is on a distinguished road
You are trying to call a non-existing constructor for the GeometricField, by forgetting to pass the 'mesh' as a constant reference. I made the small example app and compiled it in 2.2.x (nothing has changed in GeometricField, for a looong time).

Bernhard was right, your code cannot compile.

Here is the fix:

Code:
#include "fvCFD.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:

int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"

    // This code does't compile.
    //volScalarField K
    //(
        //IOobject
        //(
            //"K",
            //runTime.timeName(),
            //mesh,
            //IOobject::NO_READ,
            //IOobject::NO_WRITE
        //),
        //0.75 //  The rest doesn't matter *Cds*phase2->rho()*magUr*bp/d1
    //);
    
    volScalarField K
    (
        IOobject
        (
            "K",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
        mesh, // You forgot to pass the const ref to the mesh.
        0.75 //  The rest doesn't matter *Cds*phase2->rho()*magUr*bp/d1
    );

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    Info<< "\nEnd\n" << endl;
    return 0;
}
The latter definition of K compiles and runs.

Among the GeometricField constructors there isn't one with the signature you have tried to use : GeometricField(const IOobject& , T).

What happens in the working code above: the GeometricField(const IOobject&, const dimensioned<T>&, ...) get's called and the scalar '0.75' gets implicitly converted to the 'dimensioned<scalar>' by 'dimensioned<T>::dimensioned<T>(const T&)' constructor. Don't worry about '...', those arguments have predefined default values. If you want, you can redefine them - they are about defining types of BCs for the field K.
tomislav_maric is offline   Reply With Quote

Old   April 3, 2014, 15:10
Default
  #4
Senior Member
 
Reza
Join Date: Mar 2009
Location: Appleton, WI
Posts: 116
Rep Power: 17
triple_r is on a distinguished road
Are your sure the problem is in K? The error message says it is in object "n". I think you should be fine defining "K" as you have if it compiles. Post your definition of "n" and I might be able to help you more.
triple_r is offline   Reply With Quote

Old   April 3, 2014, 23:07
Default
  #5
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 848
Rep Power: 18
sharonyue is on a distinguished road
Thanks you guys all, especially @tomislav_maric. Your validation is feasible.

1. This is my fault. It is caused by volScalarField n.

2. I tried @tomislav_maric's method, it worked.
sharonyue is offline   Reply With Quote

Old   April 4, 2014, 05:27
Default
  #6
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21
tomislav_maric is on a distinguished road
Quote:
Originally Posted by triple_r View Post
Are your sure the problem is in K? The error message says it is in object "n". I think you should be fine defining "K" as you have if it compiles. Post your definition of "n" and I might be able to help you more.
Maybe there is another error message somewhere else, but the signature of the constructor used for "K" was wrong, try and uncomment that constructor in the code I posted, you'll se what I mean.
tomislav_maric is offline   Reply With Quote

Old   April 4, 2014, 09:46
Default
  #7
Senior Member
 
Reza
Join Date: Mar 2009
Location: Appleton, WI
Posts: 116
Rep Power: 17
triple_r is on a distinguished road
You are absolutely right, in your example the mesh has to be specified. But the owner's original K initialization was using another scalar field, so it didn't need passing the mesh. And because he mentioned that there was no compile-time errors, a constructor was matching that pattern.
triple_r is offline   Reply With Quote

Old   April 4, 2014, 09:48
Default
  #8
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 848
Rep Power: 18
sharonyue is on a distinguished road
I think both you two are right.~
sharonyue is offline   Reply With Quote

Old   April 4, 2014, 10:00
Default
  #9
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21
tomislav_maric is on a distinguished road
we are all right, the main thing is the problem got solved

@triple_r: of course, the other ctor call is valid
tomislav_maric is offline   Reply With Quote

Old   April 4, 2014, 14:08
Default
  #10
Senior Member
 
Reza
Join Date: Mar 2009
Location: Appleton, WI
Posts: 116
Rep Power: 17
triple_r is on a distinguished road
Yup! As long as the post owner is happy and his problem is solved, we are all happy
triple_r 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
[OpenFOAM.org] compile error in dynamicMesh and thermophysicalModels libraries NickG OpenFOAM Installation 3 December 30, 2019 01:21
MPI error with IBM XL compiler in the mesh constructor nick.not.used OpenFOAM Programming & Development 0 June 17, 2013 14:01
Inheriting kOmega: why can't I change the constructor? AlmostSurelyRob OpenFOAM 4 October 27, 2011 05:34
How does one initialise an OFstream in the constructor? bigphil OpenFOAM Programming & Development 2 August 18, 2011 09:48
face order in fvMesh constructor schmittp54 OpenFOAM Programming & Development 2 November 2, 2010 10:42


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