|
[Sponsors] |
May 31, 2018, 22:27 |
array of volScalarfield
|
#1 |
New Member
Anshul
Join Date: Dec 2017
Location: India
Posts: 25
Rep Power: 8 |
i tried to declare an array of type volScalarfield as-
volScalarField Xsi ( IOobject ( "Xsi", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("Xsi", dimless, 0) ); volScalarField ( IOobject ( "Xsi[" + std::to_string(4) + "]", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, Xsi[4] ); which compiled well but when I added eqn in my main code as- fo<< "\nCalculating Xsi\n" << endl; for(int i =0 ; i<5 ; i++) { volScalarField& Xsii = Xsi[i]; while (pimple.correctNonOrthogonal()) { fvScalarMatrix XsiiEqn ( fvm::ddt(Xsii)-pow(1-Xsii,n)*A_1*exp(-Ea_1/(R*T)) == fvOptions(Xsii) ); fvOptions.constrain(XsiiEqn); XsiiEqn.solve(); fvOptions.correct(Xsii); }} it displayed compilation error as follows- error: invalid initialization of reference of type ‘Foam::volScalarField& {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&}’ from expression of type ‘double’ { volScalarField& Xsii = Xsi[i]; ^ /home/anshul/OpenFOAM/OpenFOAM-dev/wmake/rules/General/transform:25: recipe for target '/home/anshul/OpenFOAM/OpenFOAM-dev/platforms/linux64Gcc62DPInt32Opt/applications/solvers/basic/ablationFoam/ablationFoam.o' failed I don't know if there is problem in my declaration of array or initialization of field Xsii Pls anyone Guide me through this. Any sort of help is highly appreciated Thank You |
|
April 30, 2020, 07:06 |
|
#2 |
Senior Member
Join Date: Dec 2019
Location: Cologne, Germany
Posts: 367
Rep Power: 8 |
if you read the error:
error: invalid initialization of reference of type ‘Foam::volScalarField& {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&}’ from expression of type ‘double’ { volScalarField& Xsii = Xsi[i]; ^ you see that you create a reference of type volScalarField and try to reference an object of type double, which is illegal. your reference type must be the same as your referenced type. |
|
Tags |
array, volscalarfield, volscalarfield list |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Adding new member function to GidaspowErgunWenYu.C of dragModel | kiang | OpenFOAM Programming & Development | 0 | June 21, 2017 06:23 |
Newly defined volScalarField "indexT" has different array ranges in paraview | nero235 | OpenFOAM Programming & Development | 1 | September 30, 2016 12:57 |
execFlowFunctionObjects - unknown field problem | Toorop | OpenFOAM Post-Processing | 16 | March 14, 2016 04:25 |
using chemkin | JMDag2004 | OpenFOAM Pre-Processing | 2 | March 8, 2016 23:38 |
writing execFlowFunctionObjects | immortality | OpenFOAM Post-Processing | 30 | September 15, 2013 07:16 |