CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to treat autoPtr<psiChemistryModel> ? (https://www.cfd-online.com/Forums/openfoam-programming-development/109791-how-treat-autoptr-psichemistrymodel.html)

Hanzo November 26, 2012 22:18

How to treat autoPtr<psiChemistryModel> ?
 
Hello together,

I have a question about a certain line of createFields.H of chemFoam:

http://foam.sourceforge.net/docs/cpp/a03249_source.html
Code:

00026    Info<< nl << "Reading thermophysicalProperties" << endl;
00027    autoPtr<psiChemistryModel> pChemistry(psiChemistryModel::New(mesh));
00028
00029    psiChemistryModel& chemistry = pChemistry();
00030    scalar dtChem = refCast<const psiChemistryModel>(chemistry).deltaTChem()[0];

What exactly is pChemistry? I see that psiChemistryModel is an abstract class and instances cannot be created using the standard constructor, right?
However, in line 29, what is pChemistry(); doing ?

Actually, what I want to do is: create a list of autoPtr<psiChemistryModel> and then perform line 29 for each entry of that list.
Here is my code which does not work:

Code:

// this part works
pChemistry.set
        (
            i,
            autoPtr<psiChemistryModel>
            (
                psiChemistryModel::New
            (
                fluidRegions[i]
            )
            ).ptr()
        );

// but this step does not work
psiChemistryModel& chemistry = (pChemistry[i])();

This results in the error:

Code:

fluid/createFluidFields.H:108: error: no match for call to ‘(Foam::psiChemistryModel) ()’

Hanzo November 28, 2012 04:53

Okay, found it. Just had to look at the implementation of
PtrList, List and psiChemistryModel :o


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