ENH: avoid readScalar, readLabel etc from dictionary (#762, #1033)

- use the dictionary 'get' methods instead of readScalar for
  additional checking

     Unchecked:  readScalar(dict.lookup("key"));
     Checked:    dict.get<scalar>("key");

- In templated classes that also inherit from a dictionary, an additional
  'template' keyword will be required. Eg,

     this->coeffsDict().template get<scalar>("key");

  For this common use case, the predefined getXXX shortcuts may be
  useful. Eg,

     this->coeffsDict().getScalar("key");
This commit is contained in:
Mark Olesen
2018-10-12 08:14:47 +02:00
parent 990d00d40d
commit 8eddcc072a
335 changed files with 1007 additions and 1127 deletions

View File

@ -62,8 +62,8 @@ Foam::rigidBodyMeshMotion::bodyMesh::bodyMesh
bodyID_(bodyID),
patches_(dict.lookup("patches")),
patchSet_(mesh.boundaryMesh().patchSet(patches_)),
di_(readScalar(dict.lookup("innerDistance"))),
do_(readScalar(dict.lookup("outerDistance"))),
di_(dict.get<scalar>("innerDistance")),
do_(dict.get<scalar>("outerDistance")),
weight_
(
IOobject
@ -248,7 +248,7 @@ void Foam::rigidBodyMeshMotion::solve()
if (test_)
{
label nIter(readLabel(coeffDict().lookup("nIter")));
const label nIter(coeffDict().get<label>("nIter"));
for (label i=0; i<nIter; i++)
{
@ -263,7 +263,7 @@ void Foam::rigidBodyMeshMotion::solve()
}
else
{
label nIter(coeffDict().lookupOrDefault("nIter", 1));
const label nIter(coeffDict().lookupOrDefault("nIter", 1));
for (label i=0; i<nIter; i++)
{

View File

@ -122,7 +122,7 @@ Foam::rigidBodyMeshMotionSolver::rigidBodyMeshMotionSolver
{
if (rhoName_ == "rhoInf")
{
rhoInf_ = readScalar(coeffDict().lookup("rhoInf"));
coeffDict().readEntry("rhoInf", rhoInf_);
}
const dictionary& bodiesDict = coeffDict().subDict("bodies");
@ -196,7 +196,7 @@ void Foam::rigidBodyMeshMotionSolver::solve()
if (test_)
{
label nIter(readLabel(coeffDict().lookup("nIter")));
const label nIter(coeffDict().get<label>("nIter"));
for (label i=0; i<nIter; i++)
{