Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • openfoam openfoam
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 426
    • Issues 426
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar

Planned maintenance at 14:00 - platform may be offline until 15:00 (UK times)

  • Development
  • openfoamopenfoam
  • Issues
  • #322
Closed
Open
Issue created Dec 01, 2016 by Mark OLESEN@markMaintainer

objectRegistry functionality

While attempting to use the subRegistry functionality to add extra information onto the mesh obr, I noticed some odd behaviour. Delving into the code, it seems to be related to how the lookupObject works. It implicitly includes a upwards recursion into the parent registry, only stopping when it hits Time. This means that adding subRegistry2("name=abc") to subRegistry1 will fail if the parent of subRegistry1 already contained an objectRegistry with the name "abc". Test-objectRegistry.C

I think we need to make this recursion an optional parameter (default = true for compatibility) to at least a few methods. It would also be a nice time to add this, for symmetry with dictionary lookupEntryPtr:

//- Lookup and return pointer to the object of the given Type,
//  return nullptr if the object was not found or had the incorrect type
template<class Type>
const Type* lookupObjectPtr(const word& name, bool recursive=true) const;

//- Lookup and return the object of the given Type,
// return nullptr if the object was not found or had the incorrect type
template<class Type>
Type* lookupObjectPtr(const word& name, bool recursive=true) const;

Then use like this:

volScalarField* fieldPtr = mesh().lookupObjectPtr<volScalarField>("foo");
if (fieldPtr)
{
    volScalarField& fld = *fieldPtr;
   ...
}

Instead of

if (mesh().foundObject<volScalarField>("foo"))
{
    volScalarField& fld = const_cast<volScalarField&>(mesh().lookupObject<volScalarField>("foo"));
   ...
}

@andy

Assignee
Assign to
Time tracking