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

Cannot use Foam defined types in local class

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 21, 2019, 07:45
Question Cannot use Foam defined types in local class
  #1
Member
 
Ashish Magar
Join Date: Jul 2016
Location: Mumbai, India
Posts: 81
Rep Power: 10
ashishmagar600 is on a distinguished road
Hello,

I am trying to build a class locally with interFoam.

I tried to follow this example : How to add a new class locally
However, the issues discussed were not resolved in that thread.

I will paste the code here, and try to explain what are the difficulties.

.H file
Code:
#ifndef chnl_H
#define chnl_H
#include<list>

namespace Foam{
class chnl
{
        private:
                int chNo;
                Foam::labelList locProc;
        public:
                chnl(int a);
                int disp();
                Foam::labelList getlocProc (Foam::labelList& gL);
};
}
.C file
Code:
#include "chnl.H"
#include<list>
//CONSTRUCTER
Foam::chnl::chnl(int b) : chNo(b) {}

int Foam::chnl::disp() { return chNo; }

Foam::labelList Foam::chnl::getlocProc (Foam::labelList& gL)
                {
                        locProc = gL;
                        return locProc;
                }
And here is the error:
Code:
chnl.H:11:9: error: ‘labelList’ in namespace ‘Foam’ does not name a type
   Foam::labelList locProc;
         ^~~~~~~~~
chnl.H:17:9: error: ‘labelList’ in namespace ‘Foam’ does not name a type
   Foam::labelList getlocProc (Foam::labelList& gL);
         ^~~~~~~~~
chnl.C:10:7: error: ‘labelList’ in namespace ‘Foam’ does not name a type
 Foam::labelList Foam::chnl::getlocProc (Foam::labelList& gL)
       ^~~~~~~~~
Initially, I used just labelList (and not Foam::labelList), but after reading some topics on StackOverflow I tried to use Foam::labelList still no success.

Can anyone point out what am I missing here?

Thanks
ashishmagar600 is offline   Reply With Quote

Old   August 21, 2019, 11:06
Default
  #2
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
Did you include the appropriate OpenFOAM headers?
adhiraj is offline   Reply With Quote

Old   August 22, 2019, 02:05
Default [solved]
  #3
Member
 
Ashish Magar
Join Date: Jul 2016
Location: Mumbai, India
Posts: 81
Rep Power: 10
ashishmagar600 is on a distinguished road
Thanks a lot.

I thought using "Foam::type" would do the thing, but after your suggestion, I check Doxygen how they have used any class with "Foam::labelList". I found out I was missing
Code:
#include "ListOps.H"
#include "labelRange.H"
This problem is solved.

Thanks.
ashishmagar600 is offline   Reply With Quote

Old   September 16, 2022, 04:33
Default
  #4
New Member
 
Mostafa
Join Date: Oct 2021
Posts: 22
Rep Power: 4
mostafa kareem is on a distinguished road
Quote:
Originally Posted by ashishmagar600 View Post
Thanks a lot.

I thought using "Foam::type" would do the thing, but after your suggestion, I check Doxygen how they have used any class with "Foam::labelList". I found out I was missing
Code:
#include "ListOps.H"
#include "labelRange.H"
This problem is solved.

Thanks.

Hello ashishmagar600,
could you help me

I'm facing similar problem , however i tried to search for headers ,but all of them failed ,

when i implement the following code

const volScalarField::GeometricBoundaryField& pbf = p.boundaryField();

i got the similar error does not name a type


createFields.H:19:23: error: ‘GeometricBoundaryField’ in ‘Foam::volScalarField {aka class Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ does not name a type
const volScalarField::GeometricBoundaryField& pbf = p.boundaryField();
mostafa kareem is offline   Reply With Quote

Reply

Tags
class, foam namespace, types


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
[CGNS] CGNS converters available mbeaudoin OpenFOAM Meshing & Mesh Conversion 137 December 14, 2018 04:20
[mesh manipulation] RefineMesh Error and Foam warning jiahui_93 OpenFOAM Meshing & Mesh Conversion 4 March 3, 2018 11:32
How to write k and epsilon before the abnormal end xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 15:33
[blockMesh] BlockMesh FOAM warning gaottino OpenFOAM Meshing & Mesh Conversion 7 July 19, 2010 14:11
[blockMesh] BlockMeshmergePatchPairs hjasak OpenFOAM Meshing & Mesh Conversion 11 August 15, 2008 07:36


All times are GMT -4. The time now is 02:00.