CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

array of volScalarfield

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 31, 2018, 21:27
Post array of volScalarfield
  #1
New Member
 
Anshul
Join Date: Dec 2017
Location: India
Posts: 25
Rep Power: 5
sonGoku is on a distinguished road
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
sonGoku is offline   Reply With Quote

Old   April 30, 2020, 06:06
Default
  #2
Senior Member
 
Join Date: Dec 2019
Location: Cologne, Germany
Posts: 233
Rep Power: 4
geth03 is on a distinguished road
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.
geth03 is offline   Reply With Quote

Reply

Tags
array, volscalarfield, volscalarfield list

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Adding new member function to GidaspowErgunWenYu.C of dragModel kiang OpenFOAM Programming & Development 0 June 21, 2017 05:23
Newly defined volScalarField "indexT" has different array ranges in paraview nero235 OpenFOAM Programming & Development 1 September 30, 2016 11:57
execFlowFunctionObjects - unknown field problem Toorop OpenFOAM Post-Processing 16 March 14, 2016 03:25
using chemkin JMDag2004 OpenFOAM Pre-Processing 2 March 8, 2016 22:38
writing execFlowFunctionObjects immortality OpenFOAM Post-Processing 30 September 15, 2013 06:16


All times are GMT -4. The time now is 15:38.