|
[Sponsors] |
April 3, 2014, 00:43 |
NO_READ specified for read-constructor
|
#1 |
Senior Member
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 848
Rep Power: 18 |
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 ); Code:
NO_READ specified for read-constructor of object n of class IOobject 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 ); PS. Even I change k to be: Code:
volScalarField K ( IOobject ( "K", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), d1 ); |
|
April 3, 2014, 06:42 |
|
#2 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
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)
|
|
April 3, 2014, 09:26 |
|
#3 |
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
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; } 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. |
|
April 3, 2014, 15:10 |
|
#4 |
Senior Member
Reza
Join Date: Mar 2009
Location: Appleton, WI
Posts: 116
Rep Power: 17 |
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.
|
|
April 3, 2014, 23:07 |
|
#5 |
Senior Member
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 848
Rep Power: 18 |
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. |
|
April 4, 2014, 05:27 |
|
#6 |
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
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.
|
|
April 4, 2014, 09:46 |
|
#7 |
Senior Member
Reza
Join Date: Mar 2009
Location: Appleton, WI
Posts: 116
Rep Power: 17 |
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.
|
|
April 4, 2014, 09:48 |
|
#8 |
Senior Member
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 848
Rep Power: 18 |
I think both you two are right.~
|
|
April 4, 2014, 14:08 |
|
#10 |
Senior Member
Reza
Join Date: Mar 2009
Location: Appleton, WI
Posts: 116
Rep Power: 17 |
Yup! As long as the post owner is happy and his problem is solved, we are all happy
|
|
|
|
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 |