mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: simplify objectRegistry access names (issue #322)
New name: findObject(), cfindObject()
Old name: lookupObjectPtr()
Return a const pointer or nullptr on failure.
New name: findObject()
Old name: --
Return a non-const pointer or nullptr on failure.
New name: getObjectPtr()
Old name: lookupObjectRefPtr()
Return a non-const pointer or nullptr on failure.
Can be called on a const object and it will perform a
const_cast.
- use these updated names and functionality in more places
NB: The older methods names are deprecated, but continue to be defined.
This commit is contained in:
@ -240,8 +240,7 @@ const Foam::coordinateSystems& Foam::coordinateSystems::New
|
||||
{
|
||||
// Previously registered?
|
||||
|
||||
const coordinateSystems* ptr =
|
||||
obr.lookupObjectPtr<coordinateSystems>(typeName);
|
||||
const coordinateSystems* ptr = obr.findObject<coordinateSystems>(typeName);
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
|
||||
@ -100,19 +100,16 @@ Foam::regionCoupledBaseGAMGInterface::regionCoupledBaseGAMGInterface
|
||||
const polyMesh& nbrMesh =
|
||||
fineRegionCoupledLduInterface_.nbrMesh();
|
||||
|
||||
if
|
||||
(
|
||||
nbrMesh.foundObject<GAMGAgglomeration>(GAMGAgglomeration::typeName)
|
||||
)
|
||||
{
|
||||
const GAMGAgglomeration& nbrAgg = nbrMesh.thisDb().lookupObject
|
||||
<
|
||||
GAMGAgglomeration
|
||||
>
|
||||
const GAMGAgglomeration* nbrAggPtr = nbrMesh.thisDb().findObject
|
||||
<GAMGAgglomeration>
|
||||
(
|
||||
GAMGAgglomeration::typeName
|
||||
);
|
||||
|
||||
if (nbrAggPtr)
|
||||
{
|
||||
const GAMGAgglomeration& nbrAgg = *nbrAggPtr;
|
||||
|
||||
label nbrLevel(-1);
|
||||
if (nbrAgg.size() > fineLevelIndex)
|
||||
{
|
||||
|
||||
@ -187,19 +187,15 @@ Foam::label Foam::regionCoupledBase::neighbPatchID() const
|
||||
{
|
||||
if (nbrPatchID_ == -1)
|
||||
{
|
||||
if
|
||||
(
|
||||
patch_.boundaryMesh().mesh().time().foundObject<polyMesh>
|
||||
const polyMesh* meshPtr =
|
||||
patch_.boundaryMesh().mesh().time().findObject<polyMesh>
|
||||
(
|
||||
nbrRegionName_
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if (meshPtr)
|
||||
{
|
||||
const polyMesh& mesh =
|
||||
patch_.boundaryMesh().mesh().time().lookupObject<polyMesh>
|
||||
(
|
||||
nbrRegionName_
|
||||
);
|
||||
const polyMesh& mesh = *meshPtr;
|
||||
|
||||
nbrPatchID_ = mesh.boundaryMesh().findPatchID(nbrPatchName_);
|
||||
|
||||
|
||||
@ -205,8 +205,8 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection
|
||||
const word subGeomName(subDict.get<word>("surface"));
|
||||
//Pout<< "Trying to find " << subGeomName << endl;
|
||||
|
||||
const searchableSurface& s =
|
||||
io.db().lookupObject<searchableSurface>(subGeomName);
|
||||
searchableSurface& s =
|
||||
io.db().lookupObjectRef<searchableSurface>(subGeomName);
|
||||
|
||||
// I don't know yet how to handle the globalSize combined with
|
||||
// regionOffset. Would cause non-consecutive indices locally
|
||||
@ -218,7 +218,7 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
subGeom_.set(surfI, &(const_cast<searchableSurface&>(s)));
|
||||
subGeom_.set(surfI, &s);
|
||||
|
||||
indexOffset_[surfI] = startIndex;
|
||||
startIndex += subGeom_[surfI].size();
|
||||
|
||||
@ -189,7 +189,7 @@ Foam::searchableSurfaceWithGaps::searchableSurfaceWithGaps
|
||||
subGeom_.set
|
||||
(
|
||||
0,
|
||||
io.db().lookupObjectRefPtr<searchableSurface>(subGeomName)
|
||||
io.db().getObjectPtr<searchableSurface>(subGeomName)
|
||||
);
|
||||
|
||||
bounds() = subGeom_[0].bounds();
|
||||
|
||||
@ -803,14 +803,15 @@ void Foam::triSurfaceMesh::getNormal
|
||||
|
||||
void Foam::triSurfaceMesh::setField(const labelList& values)
|
||||
{
|
||||
auto* fldPtr = getObjectPtr<triSurfaceLabelField>("values");
|
||||
|
||||
if (foundObject<triSurfaceLabelField>("values"))
|
||||
if (fldPtr)
|
||||
{
|
||||
lookupObjectRef<triSurfaceLabelField>("values").field() = values;
|
||||
(*fldPtr).field() = values;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto fldPtr = autoPtr<triSurfaceLabelField>::New
|
||||
fldPtr = new triSurfaceLabelField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -827,7 +828,7 @@ void Foam::triSurfaceMesh::setField(const labelList& values)
|
||||
);
|
||||
|
||||
// Store field on triMesh
|
||||
fldPtr.ptr()->store();
|
||||
fldPtr->store();
|
||||
}
|
||||
}
|
||||
|
||||
@ -838,9 +839,11 @@ void Foam::triSurfaceMesh::getField
|
||||
labelList& values
|
||||
) const
|
||||
{
|
||||
if (foundObject<triSurfaceLabelField>("values"))
|
||||
const auto* fldPtr = getObjectPtr<triSurfaceLabelField>("values");
|
||||
|
||||
if (fldPtr)
|
||||
{
|
||||
const auto& fld = lookupObject<triSurfaceLabelField>("values");
|
||||
const auto& fld = *fldPtr;
|
||||
|
||||
values.setSize(info.size());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user