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

store labelIOField in objectRegistry

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 6, 2022, 09:30
Default store labelIOField in objectRegistry
  #1
New Member
 
Join Date: Sep 2022
Posts: 18
Rep Power: 3
newGuyAtCFD is on a distinguished road
Hello to all,

I would like to know how to store a labelIOField (IOField<label>) in the object registry so that I can latter use it inside a functionObject. This is to be inserted in the codeRead section of a coded functionObject.

Currently I have:

Code:
                auto tfldPtr = tmp<IOField<label>>::New
                (
                    IOobject                       
                    (                              
                         "someName",                     
                         mesh().time().timeName(),    
                         mesh(),                      
                         IOobject::NO_READ,           
                         IOobject::NO_WRITE
                    ),                             
                    labelList(10,0)  
                );

                mesh().objectRegistry::store(tfldPtr);
But I get the error:

Code:
/usr/lib/openfoam/openfoam2206/src/OpenFOAM/lnInclude/tmpI.H: In instantiation of ‘T* Foam::tmp<T>::ptr() const [with T = Foam::IOField<int>]’:
/usr/lib/openfoam/openfoam2206/src/OpenFOAM/lnInclude/regIOobjectI.H:148:11:   required from ‘static Type& Foam::regIOobject::store(Foam::tmp<T>&) [with Type = Foam::IOField<int>]’
/home/abc/Desktop/test/system/controlDict.functions.myFunction:135:53:   required from here
/usr/lib/openfoam/openfoam2206/src/OpenFOAM/lnInclude/tmpI.H:282:18: error: request for member ‘clone’ is ambiguous
  282 |     return ptr_->clone().ptr();
What is the proper way of storing a IOField in the objectRegistry?
newGuyAtCFD is offline   Reply With Quote

Old   September 6, 2022, 10:12
Default
  #2
New Member
 
Join Date: Sep 2022
Posts: 18
Rep Power: 3
newGuyAtCFD is on a distinguished road
I think I solved it with:

Code:
            const word fieldName = "someName";

            if (!foundObject<IOField<label>>(fieldName))
            {
                autoPtr<IOField<label>> tfldPtr
                (
                    new IOField<label>
                    (
                        IOobject
                        (
                            fieldName,
                            mesh().time().timeName(),  
                            mesh(),
                            IOobject::NO_READ,
                            IOobject::NO_WRITE
                        ),
                        labelList(10, 0)
                    )
                );

                mesh().thisDb().store( tfldPtr );
            }
Please let me know if you have better approaches!

Last edited by newGuyAtCFD; September 6, 2022 at 12:45. Reason: Think I found the correct solution
newGuyAtCFD is offline   Reply With Quote

Reply


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
Question regarding objectRegistry and related subjects. granzer OpenFOAM 0 March 21, 2020 13:01
store and access the value in UDM serene6390 Fluent UDF and Scheme Programming 8 April 16, 2018 01:21
Dynamic Meshing in Store separation phoenixash11499 FLUENT 0 December 7, 2017 21:59
chtMultiRegionSimpleFoam: crash on parallel run student666 OpenFOAM Running, Solving & CFD 3 April 20, 2017 11:05
Surface area of store bharatesh CFD Freelancers 0 May 29, 2015 01:02


All times are GMT -4. The time now is 15:33.