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

Advice on understanding namespace and classes in MRF

Register Blogs Community New Posts Updated Threads Search

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   March 1, 2024, 16:49
Default Advice on understanding namespace and classes in MRF
  #1
New Member
 
Join Date: Jan 2024
Posts: 11
Rep Power: 2
gmax is on a distinguished road
Hi everyone, I've read a lot of useful information on this forum and today I wanted to learn more about c++ in OpenFoam.

I'm trying to introduce variable rotation axes into MRF. I came across a syntax that I often encounter in code but that I didn't completely understand, I report the part of the code that I'm trying to understand below:



Code:
Foam::IOobject Foam::IOMRFZoneList::createIOobject
 
(
 
    const fvMesh& mesh,
 
    const word& solverName
 
) const
 
{
 
    IOobject io
 
    (
 
        "MRFProperties" + solverName,
 
        mesh.time().constant(),
 
        mesh,
 
        IOobject::MUST_READ,
 
        IOobject::NO_WRITE
 
    );
 
 
 
    if (io.typeHeaderOk<IOdictionary>(true))
 
    {
 
        Info<< "Creating MRF zone list from " << io.name() << endl;
 
 
 
        io.readOpt(IOobject::MUST_READ_IF_MODIFIED);
 
    }
 
    else
 
    {
 
        Info<< "No MRF models present" << nl << endl;
 
 
 
        io.readOpt(IOobject::NO_READ);
 
    }
 
 
 
    return io;
 
}
From what I understand, an object of type
Code:
IOobject
is created, from the
Code:
FOAM
namespace, what I don't understand is the second part
Code:
Foam::IOMRFZoneList::createIOobject
. From this writing I would say that you are describing how the createIOobject method should work.
But in reality I don't understand this exactly, why do I create an object and then specify a method of creation for that object. Maybe I'm not understanding well what this line in C++ means and for this reason I ask you if you can describe to me what this type of writing represents.


I tried to replicate this writing by creating code like this:
.H
Code:
#include<iostream>

namespaceSchim{

classBase{
public:
voidmess(){
std::cout<<" classe base"<<std::endl;

      }
voidfunc();
int a;

};

classDeri: publicBase{
public:
voidmess(){
std::cout<<" classe deri"<<std::endl;

      }

};

}

namespaceSchim{
namespacederivato {
classnnsd: publicBase{
public:
voidfunc(int );

voidmess(){
std::cout<<" classe dentro name dentro name"<<std::endl;
       }

  };

 }




}
and .C file
Code:
#include"class.H"

void Schim::derivato::nnsd::Base::func(){
    std::cout<<" sono nuovo"<<std::endl;
};

intmain(){

int a;
a =2;
Schim::Base t1;
Schim::derivato::nnsd t2;
//Schim::Base Schim::derivato::nnsd::func(int a);
t1.mess();
t1.func();
t2.mess();
t2.func(2);

return0;
}
My attempt was to create something like:
Code:
Schim::Base Schim::derivato::nnsd::func(){ some stuf}
But this didn't work, what am I doing wrong?
gmax is offline   Reply With Quote

 


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



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