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

Global use of a volScalarField

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

Reply
 
LinkBack Thread Tools Display Modes
Old   October 10, 2017, 08:27
Default Global use of a volScalarField
  #1
New Member
 
Argyris Apost
Join Date: Nov 2014
Posts: 5
Rep Power: 5
Argyris is on a distinguished road
Dear FOAMers,

i created my own volScalarField myField in the creatFields.H:

volScalarField myField
(
IOobject
(
"myField",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("zero",dimensionSet(0,0,0,0,0,0, 0),-1.0),
);

and now i want to use it in the smoothSolver.C code as follows:

myField.internalField() = ( ...);

but the compiler says myField is out of scope. Isnt all Fields supposed to be globaly available?

Should i use some include ".H" file ?

Best regards,
Argyris
Argyris is offline   Reply With Quote

Old   October 10, 2017, 19:26
Default
  #2
New Member
 
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 26
Rep Power: 3
Marpole is on a distinguished road
Hi Argyris,

smoothSolver can take a scalarField variable (e.g. myField) as an argument and process it. If myField is directly written in the code, it would cause not in problem (not declared in this scope) as myField is not declared in smoothSolver.
Marpole is offline   Reply With Quote

Old   October 11, 2017, 08:41
Default
  #3
New Member
 
Argyris Apost
Join Date: Nov 2014
Posts: 5
Rep Power: 5
Argyris is on a distinguished road
Thank you Charles for your reply.

I went to fvMatrixSolve.C where the smoothSolver is being called and passed the myField as an arguement. However now i have the same "myField was not declared in this scope" problem in the fvMatrixSolve.C and i cant find how to pass myField in the fvMatrixSolve as an arguement as well.

Any ideas?

Argyris
Argyris is offline   Reply With Quote

Old   October 11, 2017, 23:54
Default
  #4
New Member
 
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 26
Rep Power: 3
Marpole is on a distinguished road
smoothSolver or fvMatrixSolve is used for solving linear system equation. It is odd that you need a scalar field but I believe you have your reason. I can only think of declaring myField in smoothSolver and read myField in smoothSolver where you need myField, i.e. put your following code inside smoothSolver.

Code:
volScalarField myField
(
    IOobject
    (
        "myField",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    mesh,
    dimensionedScalar("zero",dimensionSet(0,0,0,0,0,0,  0),-1.0),
);
Marpole is offline   Reply With Quote

Reply

Tags
field, global, scope, volscalarfield

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
pimpleDyMFoam computation randomly stops babapeti OpenFOAM Running, Solving & CFD 5 January 24, 2018 06:28
writing execFlowFunctionObjects immortality OpenFOAM Post-Processing 30 September 15, 2013 06:16
Upgraded from Karmic Koala 9.10 to Lucid Lynx10.04.3 bookie56 OpenFOAM Installation 8 August 13, 2011 04:03
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 02:58
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 19:07


All times are GMT -4. The time now is 01:57.