|
[Sponsors] |
November 25, 2020, 07:19 |
Declration and calculating volScalarField
|
#1 |
New Member
Elol
Join Date: Feb 2020
Posts: 16
Rep Power: 6 |
Hi everybody,
I have a problem understanding this issue, I declared volScalarField as follow; Code:
volScalarField klim ( IOobject ( "klim", runTime.timeName(), mesh_ // IOobject::MUST_READ, // IOobject::AUTO_WRITE ), mesh_ //deltaX[i] *deltaX[i]/runTime.deltaT() //totalDeltaX1/runTime.deltaT() ); and calculated it as follows; Code:
scalarField deltaX = cbrt(mesh_.V()); forAll (deltaX, i) { //deltaX[i] = mag(deltaX[i]); klim = deltaX[i] * deltaX[i]/runTime.deltaT(); } Code:
--> FOAM FATAL ERROR: cannot find file "/home/Elol/OpenFOAM/Elol-v1712/run/tests_1/0.011976/klim" Anybody knows why this is happening ? Thanks in advance. |
|
November 25, 2020, 07:44 |
|
#2 |
Senior Member
Join Date: Dec 2019
Location: Cologne, Germany
Posts: 369
Rep Power: 8 |
so klim is a volScalarField and is accessed incorrectly in the loop?
klim = deltaX[i] * deltaX[i]/runTime.deltaT(); //klim[i] is correct access |
|
November 25, 2020, 08:11 |
|
#3 |
New Member
Elol
Join Date: Feb 2020
Posts: 16
Rep Power: 6 |
Thanks for you reply,
Yes klim is volScalarField, when I tried klim[i] it gives me a compilation error as follow Code:
error: cannot convert ‘Foam::dimensionedScalar {aka Foam::dimensioned<double>}’ to ‘double’ in assignment klim[i] = deltaX[i] * deltaX[i]/runTime.deltaT(); |
|
November 25, 2020, 08:30 |
|
#4 |
Senior Member
Join Date: Dec 2019
Location: Cologne, Germany
Posts: 369
Rep Power: 8 |
obviously you didn't define the dimension of klim, so openfoam checks if dimensions match before doing calculations. so when declaring klim, also define the dimension!
|
|
November 25, 2020, 09:02 |
|
#5 |
New Member
Elol
Join Date: Feb 2020
Posts: 16
Rep Power: 6 |
Thanks.
It worked, it needed also to change the runTime.deltaT() to runTime.deltaT().value() Have a nice day. Best Regards Elol |
|
Tags |
openfoam, volscalafield |
|
|