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:
Mark Olesen
2018-10-17 16:44:10 +02:00
parent e0255cfff2
commit 8fabc32539
94 changed files with 918 additions and 952 deletions

View File

@ -38,8 +38,7 @@ functions
scalar gamma = 1.4;
scalar A = -0.3*D*UInf;
const dimensionedScalar rhoRef("rhoRef", dimDensity, 1);
const volScalarField& rho =
mesh().lookupObject<volScalarField>("rho");
const auto& rho = mesh().lookupObject<volScalarField>("rho");
const vectorField& C = mesh().C();
const scalarField x(C.component(0));
@ -47,19 +46,15 @@ functions
const scalar r2 = sqr(0.5*D/(Foam::sqrt(Foam::log(10.0))));
const scalarField Psi(A*exp(-0.5/r2*(sqr(x) + sqr(y))));
volVectorField* Uptr =
mesh().lookupObjectRefPtr<volVectorField>("U");
volScalarField* pPtr =
mesh().lookupObjectRefPtr<volScalarField>("p");
volScalarField* TPtr =
mesh().lookupObjectRefPtr<volScalarField>("T");
auto* Uptr = mesh().getObjectPtr<volVectorField>("U");
auto* pPtr = mesh().getObjectPtr<volScalarField>("p");
auto* TPtr = mesh().getObjectPtr<volScalarField>("T");
if (Uptr && pPtr && TPtr)
{
volVectorField& U = *Uptr;
volScalarField& p = *pPtr;
volScalarField& T = *TPtr;
auto& U = *Uptr;
auto& p = *pPtr;
auto& T = *TPtr;
vectorField& Uc = U.primitiveFieldRef();
Uc.replace(0, UInf - rhoRef/rho()*Psi/r2*y);