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

Modifying solver to write a variable

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

Reply
 
LinkBack Thread Tools Display Modes
Old   October 13, 2015, 03:43
Default Modifying solver to write a variable
  #1
Senior Member
 
Ehsan Asgari
Join Date: Apr 2010
Posts: 304
Rep Power: 9
syavash is on a distinguished road
Hi Foamers,

I have added the following lines to pimpleFoam to write U at inlet boundary at each time step.

Code:
word patchName = "inlet";
label patchID = mesh.boundary().findPatchID(patchName);    
   
        AverageIOField<vector> U2
(
    IOobject
    (
        "U",
        mesh.time().timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::NO_WRITE
    ),
    U.boundaryField()[ patchID ]
);

U2.write();
When I compile it, some error messages appear:

Code:
SOURCE=MypimpleFoam.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/turbulenceModels/incompressible/turbulenceModel -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/transportModels -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/transportModels/incompressible/singlePhaseTransportModel -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/finiteVolume/lnInclude -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/meshTools/lnInclude -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/fvOptions/lnInclude -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/sampling/lnInclude -IlnInclude -I. -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/OpenFOAM/lnInclude -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/MypimpleFoam.o
MypimpleFoam.C: In function ‘int main(int, char**)’:
MypimpleFoam.C:96:9: error: ‘AverageIOField’ was not declared in this scope
         AverageIOField<vector> U2
         ^
MypimpleFoam.C:96:30: error: expected primary-expression before ‘>’ token
         AverageIOField<vector> U2
                              ^
MypimpleFoam.C:107:1: error: ‘U2’ was not declared in this scope
 );
 ^
make: *** [Make/linux64GccDPOpt/MypimpleFoam.o] Error 1
When I include AverageIOField.H from timeVaryingMappedFixedValue boundary condition into the code, the following error message appears:

Code:
SOURCE=MypimpleFoam.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/turbulenceModels/incompressible/turbulenceModel -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/transportModels -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/transportModels/incompressible/singlePhaseTransportModel -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/finiteVolume/lnInclude -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/meshTools/lnInclude -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/fvOptions/lnInclude -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/sampling/lnInclude -IlnInclude -I. -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/OpenFOAM/lnInclude -I/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/MypimpleFoam.o
In file included from MypimpleFoam.C:57:0:
AverageIOField.H: In function ‘int main(int, char**)’:
AverageIOField.H:43:1: error: ‘namespace’ definition is not allowed here
 namespace Foam
 ^
In file included from AverageIOField.H:114:0,
                 from MypimpleFoam.C:57:
/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/finiteVolume/lnInclude/AverageIOField.C:30:1: error: a template declaration cannot appear at block scope
 template<class Type>
 ^
/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/finiteVolume/lnInclude/AverageIOField.C:44:1: error: expected ‘;’ before ‘template’
 template<class Type>
 ^
/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/finiteVolume/lnInclude/AverageIOField.C:57:1: error: a template declaration cannot appear at block scope
 template<class Type>
 ^
/home/syavash/OpenFOAM/OpenFOAM-2.3.1/src/finiteVolume/lnInclude/AverageIOField.C:79:1: error: expected ‘;’ before ‘template’
 template<class Type>
 ^
MypimpleFoam.C:96:9: error: ‘AverageIOField’ was not declared in this scope
         AverageIOField<vector> U2
         ^
MypimpleFoam.C:96:30: error: expected primary-expression before ‘>’ token
         AverageIOField<vector> U2
                              ^
MypimpleFoam.C:107:1: error: ‘U2’ was not declared in this scope
 );
 ^
make: *** [Make/linux64GccDPOpt/MypimpleFoam.o] Error 1
I am not a C++ expert so I have no idea how to solve this problem.
Any kind of help is appreciated .

Thanks,
Syavash
syavash is offline   Reply With Quote

Reply

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
modifying interphasechangefoam solver!! eb.nabizadeh OpenFOAM Running, Solving & CFD 0 September 17, 2013 05:20
Modifying sonicFoam to run with variable timestep - strange results dalaron OpenFOAM Programming & Development 1 September 2, 2013 07:21
Using (own) variable from turbulence model within solver Arnoldinho OpenFOAM Programming & Development 3 September 3, 2012 12:18
LES solver with variable density for incompressible liquids matthias OpenFOAM Running, Solving & CFD 1 April 26, 2010 05:46
Variable distinction in settlingFoam Solver paul OpenFOAM Running, Solving & CFD 1 September 16, 2007 11:47


All times are GMT -4. The time now is 13:26.