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

Access member function from a class in coded function object

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 25, 2024, 16:19
Default Access member function from a class in coded function object
  #1
Senior Member
 
Julio Pieri
Join Date: Sep 2017
Posts: 105
Rep Power: 8
JulioPieri is on a distinguished road
Hello all,

I'm on OF-11 writing a coded source to consume a specie based on the mass transfer coeff calculated inside Frossling.C massTransferModel.

I'm trying to access the K() member function (which returns the mass transfer coeff), but it doesn't work. I tried many things, and the most promising is this one:


Code:
 codeAddAlphaRhoSup
    #{
        const Time& time = mesh().time();
        const scalar startTime = 0.2; // avoid possibility of field not being created yet
        const vectorField& C = mesh().C();

        if (time.value() > startTime)
        {
        const Foam::diffusiveMassTransferModels::Frossling& massModel =
                mesh().thisDb().lookupObject<Foam::diffusiveMassTransferModels::Frossling>("Frossling");

        const scalarField& K = massModel .K();

        Info << "K = " << K << endl;
        }

        //  const volScalarField& O2 = mesh().lookupObject<volScalarField>("O2.water");

        // scalarField& source = eqn.source();
        
        // source = kLa*(1e-3-O2);
        

    #};
But it doesn't find the "Frossling" Object in ObjectRegistry.

Code:
--> FOAM FATAL ERROR:

    request for Frossling Frossling from objectRegistry region0 failed
    available objects of type Frossling are
0()
I believe I'm missing some C++ syntax here... Can anyone help me on how to call for a member function/method of an specific model?

Thank you!

Here is the source code: https://cpp.openfoam.org/v12/Frossling_8H_source.html

Note that I've checked many post, including these:
codeInclude in coded function in controlDict, and yPlus
Error: Request from objectRegistry failed
Extract a member function from a class by using autoPtr -> post number 5 seem to have the answer, but it's beyond my C++ understanding
JulioPieri is offline   Reply With Quote

Reply

Tags
coded, coded source, codedscalarsource, frossling, member function


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
[Other] mesh airfoil NACA0012 anand_30 OpenFOAM Meshing & Mesh Conversion 13 March 7, 2022 17:22
[OpenFOAM] Native ParaView Reader Bugs tj22 ParaView 270 January 4, 2016 11:39
latest OpenFOAM-1.6.x from git failed to compile phsieh2005 OpenFOAM Bugs 25 February 9, 2010 04:37
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 10:23
Compilation error OF1.5-dev on Suse10.3 darenyang OpenFOAM Installation 0 April 29, 2009 04:55


All times are GMT -4. The time now is 20:28.