|
[Sponsors] |
Advice on understanding namespace and classes in MRF |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 1, 2024, 16:49 |
Advice on understanding namespace and classes in MRF
|
#1 |
New Member
Join Date: Jan 2024
Posts: 11
Rep Power: 2 |
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; } Code:
IOobject Code:
FOAM Code:
Foam::IOMRFZoneList::createIOobject 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; } }; } } 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; } Code:
Schim::Base Schim::derivato::nnsd::func(){ some stuf} |
|
|
|