Merge branch 'feature-runTimeCompat' into 'develop'

long-term maintenance improvement for runTime selection tables

See merge request Development/openfoam!481
This commit is contained in:
Andrew Heather
2021-11-05 18:06:31 +00:00
373 changed files with 2776 additions and 2671 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -43,9 +43,9 @@ Foam::autoPtr<Foam::PDRDragModel> Foam::PDRDragModel::New
Info<< "Selecting drag model " << modelType << endl; Info<< "Selecting drag model " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -57,7 +57,9 @@ Foam::autoPtr<Foam::PDRDragModel> Foam::PDRDragModel::New
} }
return autoPtr<PDRDragModel> return autoPtr<PDRDragModel>
(cstrIter()(dict, turbulence, rho, U, phi)); (
ctorPtr(dict, turbulence, rho, U, phi)
);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -42,9 +42,9 @@ Foam::autoPtr<Foam::XiEqModel> Foam::XiEqModel::New
Info<< "Selecting flame-wrinkling model " << modelType << endl; Info<< "Selecting flame-wrinkling model " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -55,7 +55,7 @@ Foam::autoPtr<Foam::XiEqModel> Foam::XiEqModel::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<XiEqModel>(cstrIter()(dict, thermo, turbulence, Su)); return autoPtr<XiEqModel>(ctorPtr(dict, thermo, turbulence, Su));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -42,9 +42,9 @@ Foam::autoPtr<Foam::XiGModel> Foam::XiGModel::New
Info<< "Selecting flame-wrinkling model " << modelType << endl; Info<< "Selecting flame-wrinkling model " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -55,7 +55,7 @@ Foam::autoPtr<Foam::XiGModel> Foam::XiGModel::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<XiGModel>(cstrIter()(dict, thermo, turbulence, Su)); return autoPtr<XiGModel>(ctorPtr(dict, thermo, turbulence, Su));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -45,9 +45,9 @@ Foam::autoPtr<Foam::XiModel> Foam::XiModel::New
Info<< "Selecting flame-wrinkling model " << modelType << endl; Info<< "Selecting flame-wrinkling model " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -59,7 +59,9 @@ Foam::autoPtr<Foam::XiModel> Foam::XiModel::New
} }
return autoPtr<XiModel> return autoPtr<XiModel>
(cstrIter()(dict, thermo, turbulence, Su, rho, b, phi)); (
ctorPtr(dict, thermo, turbulence, Su, rho, b, phi)
);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2014-2015 OpenFOAM Foundation Copyright (C) 2014-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -44,9 +44,9 @@ Foam::autoPtr<Foam::mixtureViscosityModel> Foam::mixtureViscosityModel::New
Info<< "Selecting incompressible transport model " << modelType << endl; Info<< "Selecting incompressible transport model " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -58,7 +58,9 @@ Foam::autoPtr<Foam::mixtureViscosityModel> Foam::mixtureViscosityModel::New
} }
return autoPtr<mixtureViscosityModel> return autoPtr<mixtureViscosityModel>
(cstrIter()(name, dict, U, phi)); (
ctorPtr(name, dict, U, phi)
);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2014-2017 OpenFOAM Foundation Copyright (C) 2014-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -111,9 +111,9 @@ Foam::autoPtr<Foam::relativeVelocityModel> Foam::relativeVelocityModel::New
Info<< "Selecting relative velocity model " << modelType << endl; Info<< "Selecting relative velocity model " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -127,7 +127,7 @@ Foam::autoPtr<Foam::relativeVelocityModel> Foam::relativeVelocityModel::New
return return
autoPtr<relativeVelocityModel> autoPtr<relativeVelocityModel>
( (
cstrIter() ctorPtr
( (
dict.optionalSubDict(modelType + "Coeffs"), dict.optionalSubDict(modelType + "Coeffs"),
mixture mixture

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -41,9 +41,9 @@ Foam::radiation::reflectionModel::New
Info<< "Selecting reflectionModel " << modelType << endl; Info<< "Selecting reflectionModel " << modelType << endl;
const auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -54,7 +54,7 @@ Foam::radiation::reflectionModel::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<reflectionModel>(cstrIter()(dict, mesh)); return autoPtr<reflectionModel>(ctorPtr(dict, mesh));
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -54,9 +54,9 @@ Foam::temperaturePhaseChangeTwoPhaseMixture::New
Info<< "Selecting phaseChange model " << modelType << endl; Info<< "Selecting phaseChange model " << modelType << endl;
auto cstrIter = componentsConstructorTablePtr_->cfind(modelType); auto* ctorPtr = componentsConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -70,7 +70,7 @@ Foam::temperaturePhaseChangeTwoPhaseMixture::New
return return
autoPtr<temperaturePhaseChangeTwoPhaseMixture> autoPtr<temperaturePhaseChangeTwoPhaseMixture>
( (
cstrIter()(thermo, mesh) ctorPtr(thermo, mesh)
); );
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -56,9 +56,9 @@ Foam::phaseChangeTwoPhaseMixture::New
Info<< "Selecting phaseChange model " << modelType << endl; Info<< "Selecting phaseChange model " << modelType << endl;
auto cstrIter = componentsConstructorTablePtr_->cfind(modelType); auto* ctorPtr = componentsConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -69,7 +69,7 @@ Foam::phaseChangeTwoPhaseMixture::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<phaseChangeTwoPhaseMixture>(cstrIter()(U, phi)); return autoPtr<phaseChangeTwoPhaseMixture>(ctorPtr(U, phi));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -80,9 +80,9 @@ Foam::cellSizeAndAlignmentControl::New
Info<< indent << "Selecting cellSizeAndAlignmentControl " Info<< indent << "Selecting cellSizeAndAlignmentControl "
<< modelType << endl; << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -95,7 +95,7 @@ Foam::cellSizeAndAlignmentControl::New
return autoPtr<cellSizeAndAlignmentControl> return autoPtr<cellSizeAndAlignmentControl>
( (
cstrIter() ctorPtr
( (
runTime, runTime,
name, name,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -134,9 +134,9 @@ Foam::autoPtr<Foam::cellSizeFunction> Foam::cellSizeFunction::New
Info<< indent << "Selecting cellSizeFunction " << modelType << endl; Info<< indent << "Selecting cellSizeFunction " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -149,7 +149,7 @@ Foam::autoPtr<Foam::cellSizeFunction> Foam::cellSizeFunction::New
return autoPtr<cellSizeFunction> return autoPtr<cellSizeFunction>
( (
cstrIter() ctorPtr
( (
dict, dict,
surface, surface,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -67,9 +67,9 @@ Foam::autoPtr<Foam::cellSizeCalculationType> Foam::cellSizeCalculationType::New
Info<< indent << "Selecting cellSizeCalculationType " << modelType << endl; Info<< indent << "Selecting cellSizeCalculationType " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -82,7 +82,7 @@ Foam::autoPtr<Foam::cellSizeCalculationType> Foam::cellSizeCalculationType::New
return autoPtr<cellSizeCalculationType> return autoPtr<cellSizeCalculationType>
( (
cstrIter()(dict, surface, defaultCellSize) ctorPtr(dict, surface, defaultCellSize)
); );
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -72,9 +72,9 @@ Foam::autoPtr<Foam::surfaceCellSizeFunction> Foam::surfaceCellSizeFunction::New
Info<< indent << "Selecting surfaceCellSizeFunction " << modelType << endl; Info<< indent << "Selecting surfaceCellSizeFunction " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -87,7 +87,7 @@ Foam::autoPtr<Foam::surfaceCellSizeFunction> Foam::surfaceCellSizeFunction::New
return autoPtr<surfaceCellSizeFunction> return autoPtr<surfaceCellSizeFunction>
( (
cstrIter()(dict, surface, defaultCellSize) ctorPtr(dict, surface, defaultCellSize)
); );
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -61,9 +61,9 @@ Foam::autoPtr<Foam::faceAreaWeightModel> Foam::faceAreaWeightModel::New
Info<< nl << "Selecting faceAreaWeightModel " << modelType << endl; Info<< nl << "Selecting faceAreaWeightModel " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -74,7 +74,7 @@ Foam::autoPtr<Foam::faceAreaWeightModel> Foam::faceAreaWeightModel::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<faceAreaWeightModel>(cstrIter()(dict)); return autoPtr<faceAreaWeightModel>(ctorPtr(dict));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -84,9 +84,9 @@ Foam::autoPtr<Foam::initialPointsMethod> Foam::initialPointsMethod::New
Info<< nl << "Selecting initialPointsMethod " << modelType << endl; Info<< nl << "Selecting initialPointsMethod " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -100,7 +100,7 @@ Foam::autoPtr<Foam::initialPointsMethod> Foam::initialPointsMethod::New
return return
autoPtr<initialPointsMethod> autoPtr<initialPointsMethod>
( (
cstrIter() ctorPtr
( (
dict, dict,
runTime, runTime,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -65,9 +65,9 @@ Foam::autoPtr<Foam::relaxationModel> Foam::relaxationModel::New
Info<< nl << "Selecting relaxationModel " << modelType << endl; Info<< nl << "Selecting relaxationModel " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -78,7 +78,7 @@ Foam::autoPtr<Foam::relaxationModel> Foam::relaxationModel::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<relaxationModel>(cstrIter()(dict, runTime)); return autoPtr<relaxationModel>(ctorPtr(dict, runTime));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2015 OpenFOAM Foundation Copyright (C) 2013-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -48,9 +48,9 @@ Foam::searchableSurfaceFeatures::New
{ {
const word modelType(surface.type() + "Features"); const word modelType(surface.type() + "Features");
auto cstrIter = dictConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -61,7 +61,7 @@ Foam::searchableSurfaceFeatures::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<searchableSurfaceFeatures>(cstrIter()(surface, dict)); return autoPtr<searchableSurfaceFeatures>(ctorPtr(surface, dict));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -71,9 +71,9 @@ Foam::autoPtr<Foam::faceSelection> Foam::faceSelection::New
{ {
const word modelType(dict.get<word>("type")); const word modelType(dict.get<word>("type"));
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -84,7 +84,7 @@ Foam::autoPtr<Foam::faceSelection> Foam::faceSelection::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<faceSelection>(cstrIter()(name, mesh, dict)); return autoPtr<faceSelection>(ctorPtr(name, mesh, dict));
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -34,9 +35,9 @@ Foam::autoPtr<Foam::helpType> Foam::helpType::New
const word& helpTypeName const word& helpTypeName
) )
{ {
auto cstrIter = dictionaryConstructorTablePtr_->cfind(helpTypeName); auto* ctorPtr = dictionaryConstructorTable(helpTypeName);
if (!cstrIter.found()) if (!ctorPtr)
{ {
// special treatment for -help // special treatment for -help
// exit without stack trace // exit without stack trace
@ -61,7 +62,7 @@ Foam::autoPtr<Foam::helpType> Foam::helpType::New
Info<< "Selecting helpType '" << helpTypeName << "'" << endl; Info<< "Selecting helpType '" << helpTypeName << "'" << endl;
return autoPtr<helpType>(cstrIter()()); return autoPtr<helpType>(ctorPtr());
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -40,7 +40,7 @@ using namespace Foam::constant;
namespace Foam namespace Foam
{ {
defineMemberFunctionSelectionTable(PDRobstacle, read, dictRead); defineMemberFunctionSelectionTable(PDRobstacle, read, dictionary);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016 Shell Research Ltd. Copyright (C) 2016 Shell Research Ltd.
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -178,7 +178,7 @@ public:
void, void,
PDRobstacle, PDRobstacle,
read, read,
dictRead, dictionary,
( (
PDRobstacle& obs, PDRobstacle& obs,
const dictionary& dict const dictionary& dict

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -41,18 +41,20 @@ bool Foam::PDRobstacle::read(Istream& is)
const word obsType(is); const word obsType(is);
const dictionary dict(is); const dictionary dict(is);
const auto mfIter = readdictReadMemberFunctionTablePtr_->cfind(obsType); auto* mfuncPtr = readdictionaryMemberFunctionTable(obsType);
if (!mfIter.good()) if (!mfuncPtr)
{ {
FatalIOErrorInFunction(is) FatalIOErrorInLookup
<< "Unknown obstacle type: " << obsType << nl (
<< "Valid types:" << nl is,
<< readdictReadMemberFunctionTablePtr_->sortedToc() << nl "obstacle",
<< exit(FatalIOError); obsType,
*readdictionaryMemberFunctionTablePtr_
) << exit(FatalIOError);
} }
mfIter()(*this, dict); mfuncPtr(*this, dict);
return true; return true;
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -45,7 +45,7 @@ using namespace Foam::constant;
PDRobstacle, \ PDRobstacle, \
obsType, \ obsType, \
read, \ read, \
dictRead, \ dictionary, \
obsName \ obsName \
); \ ); \
} \ } \

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2020 DLR Copyright (C) 2019-2020 DLR
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,9 +46,9 @@ Foam::autoPtr<Foam::implicitFunction> Foam::implicitFunction::New
const dictionary& dict const dictionary& dict
) )
{ {
auto cstrIter = dictConstructorTablePtr_->cfind(implicitFunctionType); auto* ctorPtr = dictConstructorTable(implicitFunctionType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -59,7 +59,7 @@ Foam::autoPtr<Foam::implicitFunction> Foam::implicitFunction::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<implicitFunction>(cstrIter()(dict)); return autoPtr<implicitFunction>(ctorPtr(dict));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -41,9 +41,9 @@ Foam::tabulatedWallFunctions::tabulatedWallFunction::New
Info<< "Selecting tabulatedWallFunction " << functionName << endl; Info<< "Selecting tabulatedWallFunction " << functionName << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(functionName); auto* ctorPtr = dictionaryConstructorTable(functionName);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -54,7 +54,7 @@ Foam::tabulatedWallFunctions::tabulatedWallFunction::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<tabulatedWallFunction>(cstrIter()(dict, mesh)); return autoPtr<tabulatedWallFunction>(ctorPtr(dict, mesh));
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -72,9 +72,9 @@ Foam::surfaceFeaturesExtraction::method::New
{ {
const word modelType(dict.get<word>("extractionMethod")); const word modelType(dict.get<word>("extractionMethod"));
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -85,7 +85,7 @@ Foam::surfaceFeaturesExtraction::method::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<method>(cstrIter.val()(dict)); return autoPtr<method>(ctorPtr(dict));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2014 OpenFOAM Foundation Copyright (C) 2014 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -67,9 +67,9 @@ Foam::searchableSurfaceModifier::New
const dictionary& dict const dictionary& dict
) )
{ {
auto cstrIter = dictionaryConstructorTablePtr_->cfind(type); auto* ctorPtr = dictionaryConstructorTable(type);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -80,7 +80,7 @@ Foam::searchableSurfaceModifier::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<searchableSurfaceModifier>(cstrIter()(geometry, dict)); return autoPtr<searchableSurfaceModifier>(ctorPtr(geometry, dict));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -39,9 +39,9 @@ Foam::autoPtr<Foam::ODESolver> Foam::ODESolver::New
const word solverType(dict.get<word>("solver")); const word solverType(dict.get<word>("solver"));
Info<< "Selecting ODE solver " << solverType << endl; Info<< "Selecting ODE solver " << solverType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(solverType); auto* ctorPtr = dictionaryConstructorTable(solverType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -52,7 +52,7 @@ Foam::autoPtr<Foam::ODESolver> Foam::ODESolver::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<ODESolver>(cstrIter()(odes, dict)); return autoPtr<ODESolver>(ctorPtr(odes, dict));
} }

View File

@ -84,7 +84,7 @@ bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is)
{ {
FatalIOErrorInFunction(is) FatalIOErrorInFunction(is)
<< " stream not open for reading essential object from file " << " stream not open for reading essential object from file "
<< is.name() << is.relativeName()
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -92,7 +92,7 @@ bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is)
{ {
SeriousIOErrorInFunction(is) SeriousIOErrorInFunction(is)
<< " stream not open for reading from file " << " stream not open for reading from file "
<< is.name() << endl; << is.relativeName() << endl;
} }
return false; return false;
@ -135,8 +135,8 @@ bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is)
FatalIOErrorInFunction(is) FatalIOErrorInFunction(is)
<< " stream failure while reading header" << " stream failure while reading header"
<< " on line " << is.lineNumber() << " on line " << is.lineNumber()
<< " of file " << is.name() << " of file " << is.relativeName()
<< " for essential object" << name() << " for essential object:" << name()
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -145,7 +145,7 @@ bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is)
InfoInFunction InfoInFunction
<< "Stream failure while reading header" << "Stream failure while reading header"
<< " on line " << is.lineNumber() << " on line " << is.lineNumber()
<< " of file " << is.name() << endl; << " of file " << is.relativeName() << endl;
} }
objState_ = BAD; objState_ = BAD;

View File

@ -259,8 +259,8 @@ Foam::decomposedBlockData::readBlock
if (!headerIO.readHeader(*realIsPtr)) if (!headerIO.readHeader(*realIsPtr))
{ {
FatalIOErrorInFunction(*realIsPtr) FatalIOErrorInFunction(*realIsPtr)
<< "Problem while reading header for object " << "Problem while reading object header "
<< is.name() << nl << is.relativeName() << nl
<< exit(FatalIOError); << exit(FatalIOError);
} }
} }
@ -273,8 +273,8 @@ Foam::decomposedBlockData::readBlock
if (!headerIO.readHeader(headerStream)) if (!headerIO.readHeader(headerStream))
{ {
FatalIOErrorInFunction(headerStream) FatalIOErrorInFunction(headerStream)
<< "Problem while reading header for object " << "Problem while reading object header "
<< is.name() << nl << is.relativeName() << nl
<< exit(FatalIOError); << exit(FatalIOError);
} }
streamOptData = static_cast<IOstreamOption>(headerStream); streamOptData = static_cast<IOstreamOption>(headerStream);
@ -447,8 +447,8 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks
if (!headerIO.readHeader(*realIsPtr)) if (!headerIO.readHeader(*realIsPtr))
{ {
FatalIOErrorInFunction(*realIsPtr) FatalIOErrorInFunction(*realIsPtr)
<< "Problem while reading header for object " << "Problem while reading object header "
<< is.name() << nl << is.relativeName() << nl
<< exit(FatalIOError); << exit(FatalIOError);
} }
} }

View File

@ -28,6 +28,7 @@ License
#include "IOstream.H" #include "IOstream.H"
#include "error.H" #include "error.H"
#include "argList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -48,6 +49,12 @@ Foam::fileName& Foam::IOstream::name()
} }
Foam::fileName Foam::IOstream::relativeName() const
{
return argList::envRelativePath(this->name());
}
bool Foam::IOstream::check(const char* operation) const bool Foam::IOstream::check(const char* operation) const
{ {
return fatalCheck(operation); return fatalCheck(operation);
@ -61,7 +68,8 @@ bool Foam::IOstream::fatalCheck(const char* operation) const
if (!ok) if (!ok)
{ {
FatalIOErrorInFunction(*this) FatalIOErrorInFunction(*this)
<< "error in IOstream " << name() << " for operation " << operation << "error in IOstream " << relativeName()
<< " for operation " << operation
<< exit(FatalIOError); << exit(FatalIOError);
} }

View File

@ -201,6 +201,10 @@ public:
//- Return stream name for modification //- Return stream name for modification
virtual fileName& name(); virtual fileName& name();
//- Return the name of the stream relative to the current case.
// Uses argList::envRelativePath()
fileName relativeName() const;
// Check // Check

View File

@ -58,9 +58,9 @@ Foam::autoPtr<Foam::token::compound> Foam::token::compound::New
Istream& is Istream& is
) )
{ {
auto cstrIter = IstreamConstructorTablePtr_->cfind(compoundType); auto* ctorPtr = IstreamConstructorTable(compoundType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -71,7 +71,7 @@ Foam::autoPtr<Foam::token::compound> Foam::token::compound::New
) << abort(FatalIOError); ) << abort(FatalIOError);
} }
return autoPtr<Foam::token::compound>(cstrIter()(is)); return autoPtr<Foam::token::compound>(ctorPtr(is));
} }

View File

@ -262,7 +262,7 @@ void Foam::dictionary::checkITstream
"", // functionName "", // functionName
"", // sourceFileName "", // sourceFileName
0, // sourceFileLineNumber 0, // sourceFileLineNumber
this->name(), // ioFileName relativeName(), // ioFileName == dictionary name
is.lineNumber() // ioStartLineNumber is.lineNumber() // ioStartLineNumber
); );
@ -284,7 +284,8 @@ void Foam::dictionary::checkITstream
<< remaining << " excess tokens in stream" << nl << nl; << remaining << " excess tokens in stream" << nl << nl;
std::cerr std::cerr
<< "file: " << this->name() // ioFileName == dictionary name
<< "file: " << relativeName()
<< " at line " << is.lineNumber() << '.' << nl << " at line " << is.lineNumber() << '.' << nl
<< std::endl; << std::endl;
@ -301,7 +302,7 @@ void Foam::dictionary::checkITstream
"", // functionName "", // functionName
"", // sourceFileName "", // sourceFileName
0, // sourceFileLineNumber 0, // sourceFileLineNumber
this->name(), // ioFileName relativeName(), // ioFileName == dictionary name
is.lineNumber() // ioStartLineNumber is.lineNumber() // ioStartLineNumber
) )
<< "Entry '" << keyword << "Entry '" << keyword
@ -317,7 +318,8 @@ void Foam::dictionary::checkITstream
<< "' had no tokens in stream" << nl << nl; << "' had no tokens in stream" << nl << nl;
std::cerr std::cerr
<< "file: " << this->name() // ioFileName == dictionary name
<< "file: " << relativeName()
<< " at line " << is.lineNumber() << '.' << nl << " at line " << is.lineNumber() << '.' << nl
<< std::endl; << std::endl;
@ -340,7 +342,7 @@ void Foam::dictionary::raiseBadInput
"", // functionName "", // functionName
"", // sourceFileName "", // sourceFileName
0, // sourceFileLineNumber 0, // sourceFileLineNumber
this->name(), // ioFileName relativeName(), // ioFileName == dictionary name
is.lineNumber(), // ioStartLineNumber is.lineNumber(), // ioStartLineNumber
-1 // ioEndLineNumber -1 // ioEndLineNumber
) )
@ -401,7 +403,7 @@ const Foam::entry& Foam::dictionary::lookupEntry
{ {
FatalIOErrorInFunction(*this) FatalIOErrorInFunction(*this)
<< "Entry '" << keyword << "' not found in dictionary " << "Entry '" << keyword << "' not found in dictionary "
<< name() << nl << relativeName() << nl
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -525,7 +527,7 @@ const Foam::dictionary& Foam::dictionary::subDict
{ {
FatalIOErrorInFunction(*this) FatalIOErrorInFunction(*this)
<< "Entry '" << keyword << "' not found in dictionary " << "Entry '" << keyword << "' not found in dictionary "
<< name() << nl << relativeName() << nl
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -545,7 +547,7 @@ Foam::dictionary& Foam::dictionary::subDict
{ {
FatalIOErrorInFunction(*this) FatalIOErrorInFunction(*this)
<< "Entry '" << keyword << "' not found in dictionary " << "Entry '" << keyword << "' not found in dictionary "
<< name() << nl << relativeName() << nl
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -574,7 +576,7 @@ Foam::dictionary& Foam::dictionary::subDictOrAdd
FatalIOErrorInFunction(*this) FatalIOErrorInFunction(*this)
<< "Entry '" << keyword << "Entry '" << keyword
<< "' is not a sub-dictionary in dictionary " << "' is not a sub-dictionary in dictionary "
<< name() << nl << relativeName() << nl
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -585,7 +587,7 @@ Foam::dictionary& Foam::dictionary::subDictOrAdd
FatalIOErrorInFunction(*this) FatalIOErrorInFunction(*this)
<< "Failed to insert sub-dictionary '" << keyword << "Failed to insert sub-dictionary '" << keyword
<< "' in dictionary " << "' in dictionary "
<< name() << nl << relativeName() << nl
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -613,7 +615,7 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict
FatalIOErrorInFunction(*this) FatalIOErrorInFunction(*this)
<< "Entry '" << keyword << "Entry '" << keyword
<< "' is not a sub-dictionary in dictionary " << "' is not a sub-dictionary in dictionary "
<< name() << nl << relativeName() << nl
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -622,7 +624,7 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict
IOWarningInFunction(*this) IOWarningInFunction(*this)
<< "Entry '" << keyword << "Entry '" << keyword
<< "' found but not a sub-dictionary in dictionary " << "' found but not a sub-dictionary in dictionary "
<< name() << endl; << relativeName() << endl;
} }
// The move constructor properly qualifies the dictionary name // The move constructor properly qualifies the dictionary name
@ -649,7 +651,7 @@ const Foam::dictionary& Foam::dictionary::optionalSubDict
IOWarningInFunction(*this) IOWarningInFunction(*this)
<< "Entry '" << keyword << "Entry '" << keyword
<< "' found but not a sub-dictionary in dictionary " << "' found but not a sub-dictionary in dictionary "
<< name() << endl; << relativeName() << endl;
} }
return *this; return *this;
@ -737,7 +739,7 @@ Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
IOWarningInFunction(*this) IOWarningInFunction(*this)
<< "Problem replacing entry "<< entryPtr->keyword() << "Problem replacing entry "<< entryPtr->keyword()
<< " in dictionary " << name() << endl; << " in dictionary " << relativeName() << endl;
parent_type::remove(entryPtr); parent_type::remove(entryPtr);
@ -765,7 +767,8 @@ Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
IOWarningInFunction(*this) IOWarningInFunction(*this)
<< "Attempt to add entry " << entryPtr->keyword() << "Attempt to add entry " << entryPtr->keyword()
<< " which already exists in dictionary " << name() << endl; << " which already exists in dictionary "
<< relativeName() << endl;
delete entryPtr; delete entryPtr;
return nullptr; return nullptr;
@ -871,7 +874,7 @@ bool Foam::dictionary::merge(const dictionary& dict)
{ {
FatalIOErrorInFunction(*this) FatalIOErrorInFunction(*this)
<< "Attempted merge to self, for dictionary " << "Attempted merge to self, for dictionary "
<< name() << nl << relativeName() << nl
<< abort(FatalIOError); << abort(FatalIOError);
} }
@ -960,7 +963,7 @@ void Foam::dictionary::operator+=(const dictionary& rhs)
{ {
FatalIOErrorInFunction(*this) FatalIOErrorInFunction(*this)
<< "Attempted addition to self, for dictionary " << "Attempted addition to self, for dictionary "
<< name() << nl << relativeName() << nl
<< abort(FatalIOError); << abort(FatalIOError);
} }
@ -977,7 +980,7 @@ void Foam::dictionary::operator|=(const dictionary& rhs)
{ {
FatalIOErrorInFunction(*this) FatalIOErrorInFunction(*this)
<< "Attempted |= merging to self, for dictionary " << "Attempted |= merging to self, for dictionary "
<< name() << nl << relativeName() << nl
<< abort(FatalIOError); << abort(FatalIOError);
} }
@ -997,7 +1000,7 @@ void Foam::dictionary::operator<<=(const dictionary& rhs)
{ {
FatalIOErrorInFunction(*this) FatalIOErrorInFunction(*this)
<< "Attempted addition to self, for dictionary " << "Attempted addition to self, for dictionary "
<< name() << nl << relativeName() << nl
<< abort(FatalIOError); << abort(FatalIOError);
} }

View File

@ -50,21 +50,14 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchCompat
if (finder.good()) if (finder.good())
{ {
// Want single warning (on master), but guard with parRun to avoid if (error::warnAboutAge(alt.second) && error::master())
// Pstream::master() when Pstream has not yet been initialized
if
(
(Pstream::parRun() ? Pstream::master() : true)
&& error::warnAboutAge(alt.second)
)
{ {
std::cerr std::cerr
<< "--> FOAM IOWarning :" << nl << "--> FOAM IOWarning :" << nl
<< " Found [v" << alt.second << "] '" << " Found [v" << alt.second << "] '"
<< alt.first << "' entry instead of '" << alt.first << "' entry instead of '"
<< keyword.c_str() << "' in dictionary \"" << keyword.c_str() << "' in dictionary \""
<< name().c_str() << "\" " << relativeName() << '"' << nl
<< nl
<< std::endl; << std::endl;
error::warnAboutAge("keyword", alt.second); error::warnAboutAge("keyword", alt.second);
@ -113,7 +106,7 @@ const Foam::entry& Foam::dictionary::lookupEntryCompat
{ {
FatalIOErrorInFunction(*this) FatalIOErrorInFunction(*this)
<< "Entry '" << keyword << "' not found in dictionary " << "Entry '" << keyword << "' not found in dictionary "
<< name() << relativeName()
<< exit(FatalIOError); << exit(FatalIOError);
} }

View File

@ -125,6 +125,12 @@ public:
return dictionary::name(); return dictionary::name();
} }
//- Return scoped dictionary name relative to the current case
virtual fileName relativeName() const
{
return dictionary::relativeName();
}
//- Return line number of first token in dictionary //- Return line number of first token in dictionary
virtual label startLineNumber() const; virtual label startLineNumber() const;
@ -132,7 +138,7 @@ public:
virtual label endLineNumber() const; virtual label endLineNumber() const;
//- This entry is not a primitive, //- This entry is not a primitive,
// calling this function generates a FatalError //- calling this function generates a FatalError
virtual ITstream& stream() const; virtual ITstream& stream() const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -44,6 +44,20 @@ Foam::entry::inputMode Foam::entry::globalInputMode = inputMode::MERGE;
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
void Foam::entry::reportReadWarning
(
const IOstream& is,
const std::string& msg
)
{
std::cerr
<< "--> FOAM Warning :\n"
<< " Reading \"" << is.relativeName()
<< "\" at line " << is.lineNumber() << '\n'
<< " " << msg << std::endl;
}
void Foam::entry::resetInputMode() void Foam::entry::resetInputMode()
{ {
globalInputMode = inputMode::MERGE; globalInputMode = inputMode::MERGE;
@ -85,7 +99,7 @@ void Foam::entry::raiseBadInput(const ITstream& is) const
"", // functionName "", // functionName
"", // sourceFileName "", // sourceFileName
0, // sourceFileLineNumber 0, // sourceFileLineNumber
this->name(), // ioFileName this->relativeName(), // ioFileName
is.lineNumber() // ioStartLineNumber is.lineNumber() // ioStartLineNumber
) )
<< "Entry '" << keyword << "' with invalid input" << nl << nl << "Entry '" << keyword << "' with invalid input" << nl << nl
@ -110,7 +124,7 @@ void Foam::entry::checkITstream(const ITstream& is) const
"", // functionName "", // functionName
"", // sourceFileName "", // sourceFileName
0, // sourceFileLineNumber 0, // sourceFileLineNumber
this->name(), // ioFileName this->relativeName(), // ioFileName
is.lineNumber() // ioStartLineNumber is.lineNumber() // ioStartLineNumber
); );
@ -132,7 +146,7 @@ void Foam::entry::checkITstream(const ITstream& is) const
<< remaining << " excess tokens in stream" << nl << nl; << remaining << " excess tokens in stream" << nl << nl;
std::cerr std::cerr
<< "file: " << this->name() << "file: " << this->relativeName()
<< " at line " << is.lineNumber() << '.' << nl << " at line " << is.lineNumber() << '.' << nl
<< std::endl; << std::endl;
@ -149,7 +163,7 @@ void Foam::entry::checkITstream(const ITstream& is) const
"", // functionName "", // functionName
"", // sourceFileName "", // sourceFileName
0, // sourceFileLineNumber 0, // sourceFileLineNumber
this->name(), // ioFileName this->relativeName(), // ioFileName
is.lineNumber() // ioStartLineNumber is.lineNumber() // ioStartLineNumber
) )
<< "Entry '" << keyword << "Entry '" << keyword
@ -165,7 +179,7 @@ void Foam::entry::checkITstream(const ITstream& is) const
<< "' had no tokens in stream" << nl << nl; << "' had no tokens in stream" << nl << nl;
std::cerr std::cerr
<< "file: " << this->name() << "file: " << this->relativeName()
<< " at line " << is.lineNumber() << '.' << nl << " at line " << is.lineNumber() << '.' << nl
<< std::endl; << std::endl;

View File

@ -87,7 +87,7 @@ public:
private: private:
// Private data // Private Data
//- Keyword of entry //- Keyword of entry
keyType keyword_; keyType keyword_;
@ -114,6 +114,14 @@ private:
void raiseBadInput(const ITstream& is) const; void raiseBadInput(const ITstream& is) const;
protected:
// Protected Member Functions
//- Report a read warning (on std::cerr)
static void reportReadWarning(const IOstream&, const std::string&);
public: public:
//- Enable or disable use of function entries and variable expansions. //- Enable or disable use of function entries and variable expansions.
@ -202,6 +210,9 @@ public:
//- Return the entry name for modification //- Return the entry name for modification
virtual fileName& name() = 0; virtual fileName& name() = 0;
//- Return the entry name relative to the current case
virtual fileName relativeName() const = 0;
//- Return line number of first token in dictionary //- Return line number of first token in dictionary
virtual label startLineNumber() const = 0; virtual label startLineNumber() const = 0;

View File

@ -92,10 +92,11 @@ bool Foam::entry::getKeyword(keyType& keyword, Istream& is)
<< "--> FOAM Warning :" << nl << "--> FOAM Warning :" << nl
<< " From function " << FUNCTION_NAME << nl << " From function " << FUNCTION_NAME << nl
<< " in file " << __FILE__ << " at line " << __LINE__ << nl << " in file " << __FILE__ << " at line " << __LINE__ << nl
<< " Reading " << is.name() << nl << " Reading " << is.relativeName() << nl
<< " found " << keyToken << nl << " found " << keyToken << nl
<< " expected either " << token::END_BLOCK << " or EOF" << " expected either " << token::END_BLOCK << " or EOF"
<< std::endl; << std::endl;
return false; return false;
} }

View File

@ -68,8 +68,9 @@ Foam::string Foam::functionEntries::calcEntry::evaluate
) )
{ {
DetailInfo DetailInfo
<< "Using #calc at line " << is.lineNumber() << "Using #calc - line "
<< " in file " << parentDict.name() << endl; << is.lineNumber() << " in file "
<< parentDict.relativeName() << nl;
dynamicCode::checkSecurity dynamicCode::checkSecurity
( (

View File

@ -356,7 +356,7 @@ Foam::string Foam::functionEntries::codeStream::evaluate
{ {
DetailInfo DetailInfo
<< "Using #codeStream at line " << is.lineNumber() << "Using #codeStream at line " << is.lineNumber()
<< " in file " << parentDict.name() << endl; << " in file " << parentDict.relativeName() << endl;
dynamicCode::checkSecurity dynamicCode::checkSecurity
( (

View File

@ -58,25 +58,6 @@ namespace functionEntries
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace
{
// This is akin to a SafeIOWarning, which does not yet exist
inline void safeIOWarning
(
const Foam::IOstream& is,
const std::string& msg
)
{
std::cerr
<< "--> FOAM Warning :\n"
<< " Reading \"" << is.name() << "\" at line "
<< is.lineNumber() << '\n'
<< " " << msg << std::endl;
}
} // End anonymous namespace
namespace Foam namespace Foam
{ {
@ -158,8 +139,6 @@ static bool slurpUntilBalancedBrace(ISstream& is, std::string& str)
str.append(buf, nChar); // Finalize pending content str.append(buf, nChar); // Finalize pending content
safeIOWarning(is, "Premature end while reading expression - missing '}'?");
is.fatalCheck(FUNCTION_NAME); is.fatalCheck(FUNCTION_NAME);
return false; return false;
} }
@ -252,7 +231,8 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate
{ {
InfoErr InfoErr
<< "Empty #eval - line " << "Empty #eval - line "
<< is.lineNumber() << " in file " << parentDict.name() << nl; << is.lineNumber() << " in file "
<< parentDict.relativeName() << nl;
return tokenList(); return tokenList();
} }
@ -268,7 +248,8 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate
{ {
InfoErr InfoErr
<< "Failed #eval - line " << "Failed #eval - line "
<< is.lineNumber() << " in file " << parentDict.name() << nl; << is.lineNumber() << " in file "
<< parentDict.relativeName() << nl;
return tokenList(); return tokenList();
} }
@ -296,7 +277,8 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate
#ifdef FULLDEBUG #ifdef FULLDEBUG
DetailInfo DetailInfo
<< "Using #eval - line " << "Using #eval - line "
<< is.lineNumber() << " in file " << parentDict.name() << nl; << is.lineNumber() << " in file "
<< parentDict.relativeName() << nl;
#endif #endif
token tok(is); token tok(is);
@ -321,7 +303,14 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate
else if (tok.isPunctuation(token::BEGIN_BLOCK)) else if (tok.isPunctuation(token::BEGIN_BLOCK))
{ {
// - #eval { expr } // - #eval { expr }
slurpUntilBalancedBrace(dynamic_cast<ISstream&>(is), str); if (!slurpUntilBalancedBrace(dynamic_cast<ISstream&>(is), str))
{
reportReadWarning
(
is,
"Premature end while reading expression - missing '}'?"
);
}
} }
else else
{ {

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -99,21 +100,21 @@ bool Foam::functionEntry::execute
return true; return true;
} }
auto mfIter = auto* mfuncPtr =
executedictionaryIstreamMemberFunctionTablePtr_->cfind(functionName); executedictionaryIstreamMemberFunctionTable(functionName);
if (!mfIter.found()) if (!mfuncPtr)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown functionEntry '" << functionName << "Unknown functionEntry '" << functionName
<< "' in " << is.name() << " near line " << is.lineNumber() << "' in " << is.relativeName()
<< nl << nl << " near line " << is.lineNumber() << nl << nl
<< "Valid functionEntries :" << endl << "Valid functionEntries :" << nl
<< executedictionaryIstreamMemberFunctionTablePtr_->sortedToc() << executedictionaryIstreamMemberFunctionTablePtr_->sortedToc()
<< exit(FatalError); << exit(FatalError);
} }
return mfIter()(parentDict, is); return mfuncPtr(parentDict, is);
} }
@ -138,24 +139,21 @@ bool Foam::functionEntry::execute
return true; return true;
} }
auto mfIter = auto* mfuncPtr =
executeprimitiveEntryIstreamMemberFunctionTablePtr_->cfind executeprimitiveEntryIstreamMemberFunctionTable(functionName);
(
functionName
);
if (!mfIter.found()) if (!mfuncPtr)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown functionEntry '" << functionName << "Unknown functionEntry '" << functionName
<< "' in " << is.name() << " near line " << is.lineNumber() << "' in " << is.relativeName()
<< nl << nl << " near line " << is.lineNumber() << nl << nl
<< "Valid functionEntries :" << endl << "Valid functionEntries :" << nl
<< executeprimitiveEntryIstreamMemberFunctionTablePtr_->sortedToc() << executeprimitiveEntryIstreamMemberFunctionTablePtr_->sortedToc()
<< exit(FatalError); << exit(FatalError);
} }
return mfIter()(parentDict, entry, is); return mfuncPtr(parentDict, entry, is);
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -48,15 +49,15 @@ SourceFiles
#ifndef functionEntry_H #ifndef functionEntry_H
#define functionEntry_H #define functionEntry_H
#include "word.H"
#include "memberFunctionSelectionTables.H"
#include "primitiveEntry.H" #include "primitiveEntry.H"
#include "memberFunctionSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
// Forward Declarations
class dictionary; class dictionary;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -67,17 +68,10 @@ class functionEntry
: :
public primitiveEntry public primitiveEntry
{ {
// Private Member Functions
//- No copy construct
functionEntry(const functionEntry&) = delete;
//- No copy assignment
void operator=(const functionEntry&) = delete;
protected: protected:
// Protected Member Functions
//- Read line and return as a string token //- Read line and return as a string token
static token readLine(const word& key, Istream& is); static token readLine(const word& key, Istream& is);
@ -86,6 +80,12 @@ protected:
template<class StringType> template<class StringType>
static List<StringType> readStringList(Istream& is); static List<StringType> readStringList(Istream& is);
//- No copy construct
functionEntry(const functionEntry&) = delete;
//- No copy assignment
void operator=(const functionEntry&) = delete;
public: public:
// Constructors // Constructors

View File

@ -391,8 +391,8 @@ bool Foam::functionEntries::ifeqEntry::execute
if (ifEntry::isTrue(e.stream())) if (ifEntry::isTrue(e.stream()))
{ {
// Info<< "Using #elif " << doIf << " at line " << lineNo // Info<< "Using #elif " << doIf << " - line " << lineNo
// << " in file " << is.name() << endl; // << " in file " << is.relativeName() << endl;
break; break;
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -170,7 +170,7 @@ bool Foam::functionEntries::includeEntry::execute
FatalIOErrorInFunction(is) FatalIOErrorInFunction(is)
<< "Cannot open include file " << "Cannot open include file "
<< (ifs.name().size() ? ifs.name() : rawName) << (ifs.name().size() ? ifs.name() : rawName)
<< " while reading dictionary " << parentDict.name() << " while reading dictionary " << parentDict.relativeName()
<< exit(FatalIOError); << exit(FatalIOError);
return false; return false;
@ -222,7 +222,7 @@ bool Foam::functionEntries::includeEntry::execute
FatalIOErrorInFunction(is) FatalIOErrorInFunction(is)
<< "Cannot open include file " << "Cannot open include file "
<< (ifs.name().size() ? ifs.name() : rawName) << (ifs.name().size() ? ifs.name() : rawName)
<< " while reading dictionary " << parentDict.name() << " while reading dictionary " << parentDict.relativeName()
<< exit(FatalIOError); << exit(FatalIOError);
return false; return false;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015-2017 OpenFOAM Foundation Copyright (C) 2015-2017 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -138,7 +138,7 @@ bool Foam::functionEntries::includeEtcEntry::execute
FatalIOErrorInFunction(is) FatalIOErrorInFunction(is)
<< "Cannot open etc file " << "Cannot open etc file "
<< (ifs.name().size() ? ifs.name() : rawName) << (ifs.name().size() ? ifs.name() : rawName)
<< " while reading dictionary " << parentDict.name() << " while reading dictionary " << parentDict.relativeName()
<< exit(FatalIOError); << exit(FatalIOError);
return false; return false;
@ -178,7 +178,7 @@ bool Foam::functionEntries::includeEtcEntry::execute
FatalIOErrorInFunction(is) FatalIOErrorInFunction(is)
<< "Cannot open etc file " << "Cannot open etc file "
<< (ifs.name().size() ? ifs.name() : rawName) << (ifs.name().size() ? ifs.name() : rawName)
<< " while reading dictionary " << parentDict.name() << " while reading dictionary " << parentDict.relativeName()
<< exit(FatalIOError); << exit(FatalIOError);
return false; return false;

View File

@ -155,6 +155,12 @@ public:
return ITstream::name(); return ITstream::name();
} }
//- Return token stream name relative to the current case
virtual fileName relativeName() const
{
return ITstream::relativeName();
}
//- Return line number of first token in dictionary //- Return line number of first token in dictionary
virtual label startLineNumber() const; virtual label startLineNumber() const;

View File

@ -30,27 +30,6 @@ License
#include "functionEntry.H" #include "functionEntry.H"
#include "evalEntry.H" #include "evalEntry.H"
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace
{
// This is akin to a SafeIOWarning, which does not yet exist
inline void safeIOWarning
(
const Foam::IOstream& is,
const std::string& msg
)
{
std::cerr
<< "--> FOAM Warning :\n"
<< " Reading \"" << is.name() << "\" at line "
<< is.lineNumber() << '\n'
<< " " << msg << std::endl;
}
} // End anonymous namespace
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::primitiveEntry::acceptToken bool Foam::primitiveEntry::acceptToken
@ -182,7 +161,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is)
--depth; --depth;
if (depth < 0) if (depth < 0)
{ {
safeIOWarning reportReadWarning
( (
is, is,
"Too many closing ')' ... was a ';' forgotten?" "Too many closing ')' ... was a ';' forgotten?"
@ -191,7 +170,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is)
else if (depth < 61 && ((balanced >> depth) & 1u)) else if (depth < 61 && ((balanced >> depth) & 1u))
{ {
// Bit was set, but expected it to be unset. // Bit was set, but expected it to be unset.
safeIOWarning(is, "Imbalanced '{' with ')'"); reportReadWarning(is, "Imbalanced '{' with ')'");
} }
} }
break; break;
@ -201,7 +180,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is)
--depth; --depth;
if (depth < 0) if (depth < 0)
{ {
safeIOWarning reportReadWarning
( (
is, is,
"Too many closing '}' ... was a ';' forgotten?" "Too many closing '}' ... was a ';' forgotten?"
@ -210,7 +189,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is)
else if (depth < 61 && !((balanced >> depth) & 1u)) else if (depth < 61 && !((balanced >> depth) & 1u))
{ {
// Bit was unset, but expected it to be set. // Bit was unset, but expected it to be set.
safeIOWarning(is, "Imbalanced '(' with '}'"); reportReadWarning(is, "Imbalanced '(' with '}'");
} }
} }
break; break;
@ -230,7 +209,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is)
if (depth) if (depth)
{ {
safeIOWarning(is, "Imbalanced brackets"); reportReadWarning(is, "Imbalanced brackets");
} }
is.fatalCheck(FUNCTION_NAME); is.fatalCheck(FUNCTION_NAME);

View File

@ -27,7 +27,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "error.H" #include "error.H"
#include "argList.H"
#include "StringStream.H" #include "StringStream.H"
#include "fileName.H" #include "fileName.H"
#include "dictionary.H" #include "dictionary.H"
@ -100,7 +99,7 @@ Foam::OSstream& Foam::IOerror::operator()
functionName, functionName,
sourceFileName, sourceFileName,
sourceFileLineNumber, sourceFileLineNumber,
argList::envRelativePath(ioStream.name()), ioStream.relativeName(),
ioStream.lineNumber(), ioStream.lineNumber(),
-1 // No known endLineNumber -1 // No known endLineNumber
); );
@ -137,8 +136,8 @@ Foam::OSstream& Foam::IOerror::operator()
( (
where.c_str(), where.c_str(),
"", // No source file "", // No source file
1, // Non-zero to ensure that 'where' is reported -1, // Non-zero to ensure 'where' is reported
argList::envRelativePath(ioStream.name()), ioStream.relativeName(),
ioStream.lineNumber(), ioStream.lineNumber(),
-1 // No known endLineNumber -1 // No known endLineNumber
); );
@ -155,7 +154,7 @@ Foam::OSstream& Foam::IOerror::operator()
( (
where.c_str(), where.c_str(),
"", // No source file "", // No source file
1, // Non-zero to ensure that 'where' is reported -1, // Non-zero to ensure 'where' is reported
dict.relativeName(), dict.relativeName(),
dict.startLineNumber(), dict.startLineNumber(),
dict.endLineNumber() dict.endLineNumber()
@ -188,7 +187,7 @@ void Foam::IOerror::SafeFatalIOError
<< nl << nl
<< "--> FOAM FATAL IO ERROR:" << nl << "--> FOAM FATAL IO ERROR:" << nl
<< msg << nl << msg << nl
<< "file: " << ioStream.name() << "file: " << ioStream.relativeName()
<< " at line " << ioStream.lineNumber() << '.' << nl << nl << " at line " << ioStream.lineNumber() << '.' << nl << nl
<< " From " << functionName << nl << " From " << functionName << nl
<< " in file " << sourceFileName << " in file " << sourceFileName
@ -253,7 +252,7 @@ void Foam::IOerror::abort()
} }
void Foam::IOerror::write(Ostream& os, const bool includeTitle) const void Foam::IOerror::write(Ostream& os, const bool withTitle) const
{ {
if (os.bad()) if (os.bad())
{ {
@ -261,7 +260,7 @@ void Foam::IOerror::write(Ostream& os, const bool includeTitle) const
} }
os << nl; os << nl;
if (includeTitle && !title().empty()) if (withTitle && !title().empty())
{ {
os << title().c_str() os << title().c_str()
<< "(openfoam-" << foamVersion::api; << "(openfoam-" << foamVersion::api;

View File

@ -38,6 +38,20 @@ License
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
bool Foam::error::master(const label communicator)
{
// Trap negative value for comm as 'default'. This avoids direct use
// of Pstream::worldComm which may not have been initialised
return
(
UPstream::parRun()
? (communicator < 0 ? UPstream::master() : UPstream::master(communicator))
: true
);
}
bool Foam::error::warnAboutAge(const int version) noexcept bool Foam::error::warnAboutAge(const int version) noexcept
{ {
// No warning for 0 (unversioned) or -ve values (silent versioning) // No warning for 0 (unversioned) or -ve values (silent versioning)
@ -245,20 +259,20 @@ void Foam::error::simpleExit(const int errNo, const bool isAbort)
error::printStack(Perr); error::printStack(Perr);
std::abort(); std::abort();
} }
else if (Pstream::parRun()) else if (UPstream::parRun())
{ {
if (isAbort) if (isAbort)
{ {
Perr<< nl << *this << nl Perr<< nl << *this << nl
<< "\nFOAM parallel run aborting\n" << endl; << "\nFOAM parallel run aborting\n" << endl;
error::printStack(Perr); error::printStack(Perr);
Pstream::abort(); UPstream::abort();
} }
else else
{ {
Perr<< nl << *this << nl Perr<< nl << *this << nl
<< "\nFOAM parallel run exiting\n" << endl; << "\nFOAM parallel run exiting\n" << endl;
Pstream::exit(errNo); UPstream::exit(errNo);
} }
} }
else else
@ -326,7 +340,7 @@ void Foam::error::abort()
} }
void Foam::error::write(Ostream& os, const bool includeTitle) const void Foam::error::write(Ostream& os, const bool withTitle) const
{ {
if (os.bad()) if (os.bad())
{ {
@ -334,7 +348,7 @@ void Foam::error::write(Ostream& os, const bool includeTitle) const
} }
os << nl; os << nl;
if (includeTitle && !title().empty()) if (withTitle && !title().empty())
{ {
os << title().c_str() os << title().c_str()
<< "(openfoam-" << foamVersion::api; << "(openfoam-" << foamVersion::api;

View File

@ -119,6 +119,13 @@ public:
// Static Functions // Static Functions
//- Like Pstream::master but with a Pstream::parRun guard in case
//- Pstream has not yet been initialised.
//
// \param communicator is the numbered MPI communicator.
// By default it uses UPstream::worldComm
static bool master(const label communicator = -1);
//- Test if an age warning should be emitted. //- Test if an age warning should be emitted.
// \param version is the old version (YYMM) for determining the // \param version is the old version (YYMM) for determining the
// age in months compared to the current OpenFOAM version // age in months compared to the current OpenFOAM version
@ -244,7 +251,7 @@ public:
void abort(); void abort();
//- Print error message //- Print error message
virtual void write(Ostream& os, const bool includeTitle = true) const; virtual void write(Ostream& os, const bool withTitle = true) const;
// Housekeeping // Housekeeping
@ -405,7 +412,7 @@ public:
void abort(); void abort();
//- Print error message //- Print error message
virtual void write(Ostream& os, const bool includeTitle = true) const; virtual void write(Ostream& os, const bool withTitle = true) const;
}; };

View File

@ -80,10 +80,10 @@ Foam::OSstream& Foam::messageStream::stream(OSstream* alternative)
|| severity_ == INFO_STDERR || severity_ == INFO_STDERR
|| severity_ == WARNING || severity_ == WARNING
) )
|| !Pstream::parRun() || !UPstream::parRun()
); );
if (serialOnly && (Pstream::parRun() && !Pstream::master())) if (serialOnly && (UPstream::parRun() && !UPstream::master()))
{ {
return Snull; // Non-serial, non-master: exit early return Snull; // Non-serial, non-master: exit early
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -108,9 +108,9 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
<< exit(FatalError); << exit(FatalError);
} }
auto cstrIter = dictionaryConstructorTablePtr_->cfind(functionType); auto* ctorPtr = dictionaryConstructorTable(functionType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
// FatalError (not FatalIOError) to ensure it can be caught // FatalError (not FatalIOError) to ensure it can be caught
// as an exception and ignored // as an exception and ignored
@ -122,7 +122,7 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
) << exit(FatalError); ) << exit(FatalError);
} }
return autoPtr<functionObject>(cstrIter()(name, runTime, dict)); return autoPtr<functionObject>(ctorPtr(name, runTime, dict));
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,6 +27,10 @@ License
Description Description
Macros for easy insertion into run-time selection tables Macros for easy insertion into run-time selection tables
Note
The helper macro names used here must remain synchronized with
definitions in runTimeSelectionTables.H
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef addToRunTimeSelectionTable_H #ifndef addToRunTimeSelectionTable_H
@ -33,88 +38,119 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Add to hash-table of functions with typename as the key //- Add to construction table with typeName as the key
#define addToRunTimeSelectionTable\ #define addToRunTimeSelectionTable\
(baseType,thisType,argNames) \ (baseType,thisType,argNames) \
\ \
/* Add the thisType constructor function to the table */ \ /* Add thisType factory method to the table */ \
baseType::add##argNames##ConstructorToTable<thisType> \ baseType::add##argNames##ConstructorToTable<thisType> \
add##thisType##argNames##ConstructorTo##baseType##Table_ add##thisType##argNames##ConstructorTo##baseType##Table_
//- Add to hash-table of functions with 'lookup' as the key //- Add to construction table with typeName as the key
#define addNamedToRunTimeSelectionTable\
(baseType,thisType,argNames,lookup) \
\
/* Add the thisType constructor function to the table, find by lookup */ \
baseType::add##argNames##ConstructorToTable<thisType> \
add_##lookup##_##thisType##argNames##ConstructorTo##baseType##Table_ \
(#lookup)
//- Add to hash-table of functions with typename as the key
#define addRemovableToRunTimeSelectionTable\ #define addRemovableToRunTimeSelectionTable\
(baseType,thisType,argNames) \ (baseType,thisType,argNames) \
\ \
/* Add the thisType constructor function to the table */ \ /* Add thisType factory method to the table */ \
baseType::addRemovable##argNames##ConstructorToTable<thisType> \ baseType::addRemovable##argNames##ConstructorToTable<thisType> \
addRemovable##thisType##argNames##ConstructorTo##baseType##Table_ addRemovable##thisType##argNames##ConstructorTo##baseType##Table_
//- Add to hash-table of functions with 'lookup' as the key //- Add to construction table with 'lookupName' as the key
#define addRemovableNamedToRunTimeSelectionTable\ #define addNamedToRunTimeSelectionTable\
(baseType,thisType,argNames,lookup) \ (baseType,thisType,argNames,lookupName) \
\ \
/* Add the thisType constructor function to the table, find by lookup */ \ /* Add thisType factory method to the table, find by lookupName */ \
baseType::add##argNames##ConstructorToTable<thisType> \
add##thisType##argNames##ConstructorTo## \
baseType##Table_##lookupName##_(#lookupName)
//- Add to construction table with 'lookupName' as the key
#define addRemovableNamedToRunTimeSelectionTable\
(baseType,thisType,argNames,lookupName) \
\
/* Add thisType factory method to the table, find by lookupName */ \
baseType::addRemovable##argNames##ConstructorToTable<thisType> \ baseType::addRemovable##argNames##ConstructorToTable<thisType> \
addRemovable_##lookup##_##thisType##argNames##ConstructorTo \ addRemovable##thisType##argNames##ConstructorTo## \
##baseType##Table_(#lookup) baseType##Table_##lookupName##_(#lookupName)
//- Add lookup alias for runTime selection
#define addAliasToRunTimeSelectionTable\
(baseType,thisType,argNames,lookup,other,ver) \
\
/* Add thisType constructor function to the table, find by lookup */ \
baseType::addAlias##argNames##ConstructorToTable<thisType> \
add##thisType##argNames##ConstructorTo##baseType##Table_ \
##lookup##_##other##_(#lookup,#other,ver)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Add to hash-table of functions with typename as the key. //- Add to construction table with typeName as the key.
// Use when baseType doesn't need a template argument (eg, is a typedef) // Use when baseType doesn't need a template argument (eg, is a typedef)
#define addTemplateToRunTimeSelectionTable\ #define addTemplateToRunTimeSelectionTable\
(baseType,thisType,Targ,argNames) \ (baseType,thisType,Targ,argNames) \
\ \
/* Add the thisType constructor function to the table */ \ /* Add thisType factory method to the table */ \
baseType::add##argNames##ConstructorToTable<thisType<Targ>> \ baseType::add##argNames##ConstructorToTable<thisType<Targ>> \
add##thisType##Targ##argNames##ConstructorTo##baseType##Table_ add##thisType##Targ##argNames##ConstructorTo##baseType##Table_
//- Add to hash-table of functions with 'lookup' as the key. //- Add to construction table with 'lookupName' as the key.
// Use when baseType doesn't need a template argument (eg, is a typedef) // Use when baseType doesn't need a template argument (eg, is a typedef)
#define addNamedTemplateToRunTimeSelectionTable\ #define addNamedTemplateToRunTimeSelectionTable\
(baseType,thisType,Targ,argNames,lookup) \ (baseType,thisType,Targ,argNames,lookupName) \
\ \
/* Add the thisType constructor function to the table, find by lookup */ \ /* Add thisType factory method to the table, find by lookupName */ \
baseType::add##argNames##ConstructorToTable<thisType<Targ>> \ baseType::add##argNames##ConstructorToTable<thisType<Targ>> \
add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType \ add##thisType##Targ##argNames##ConstructorTo## \
##Table_(#lookup) baseType##Table_##lookupName##_(#lookupName)
//- Add lookup alias for for runTime selection
#define addAliasTemplateToRunTimeSelectionTable\
(baseType,thisType,Targ,argNames,lookup,other,ver) \
\
/* Add thisType constructor function to the table, find by lookup */ \
baseType::addAlias##argNames##ConstructorToTable<thisType<Targ>> \
add##thisType##Targs##argNames##ConstructorTo##baseType##Table_ \
##lookup##_##other##_(#lookup,#other,ver)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Add to hash-table of functions with typename as the key. //- Add to construction table with typeName as the key.
// Use when baseType requires the Targ template argument as well // Use when baseType requires the Targ template argument as well
#define addTemplatedToRunTimeSelectionTable\ #define addTemplatedToRunTimeSelectionTable\
(baseType,thisType,Targ,argNames) \ (baseType,thisType,Targ,argNames) \
\ \
/* Add the thisType constructor function to the table */ \ /* Add thisType factory method to the table */ \
baseType<Targ>::add##argNames##ConstructorToTable<thisType<Targ>> \ baseType<Targ>::add##argNames##ConstructorToTable<thisType<Targ>> \
add##thisType##Targ##argNames##ConstructorTo##baseType##Targ##Table_ add##thisType##Targ##argNames##ConstructorTo##baseType##Targ##Table_
//- Add to hash-table of functions with 'lookup' as the key. //- Add to construction table with 'lookupName' as the key.
// Use when baseType requires the Targ template argument as well // Use when baseType requires the Targ template argument as well
#define addNamedTemplatedToRunTimeSelectionTable\ #define addNamedTemplatedToRunTimeSelectionTable\
(baseType,thisType,Targ,argNames,lookup) \ (baseType,thisType,Targ,argNames,lookupName) \
\
/* Add thisType factory method to the table, find by lookupName */ \
baseType<Targ>::add##argNames##ConstructorToTable<thisType<Targ>> \
add##thisType##Targ##argNames##ConstructorTo## \
baseType##Targ##Table_##lookupName##_(#lookupName)
//- Add lookup alias for for runTime selection
// Use when baseType requires the Targ template argument as well
#define addAliasTemplatedToRunTimeSelectionTable\
(baseType,thisType,Targ,argNames,lookup,other,ver) \
\ \
/* Add the thisType constructor function to the table, find by lookup */ \ /* Add the thisType constructor function to the table, find by lookup */ \
baseType<Targ>::add##argNames##ConstructorToTable<thisType<Targ>> \ baseType<Targ>::add##argNames##ConstructorToTable<thisType<Targ>> \
add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType## \ add##thisType##Targ##argNames##ConstructorTo##baseType##Targ## \
Targ##Table_(#lookup) Table_##lookup##_##other##_(#lookup,#other,ver)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -40,339 +40,358 @@ Description
#ifndef runTimeSelectionTables_H #ifndef runTimeSelectionTables_H
#define runTimeSelectionTables_H #define runTimeSelectionTables_H
#include <memory> // For std::unique_ptr
#include <utility> // For std::pair
#include "autoPtr.H" #include "autoPtr.H"
#include "HashTable.H" #include "HashTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Declare a run-time selection // Common infrastructure
#define declareRunTimeSelectionTable(autoPtr,baseType,argNames,argList,parList)\
// Not used directly: declare run-time selection (variables and methods)
#define declareRunTimeSelectionTableBase(returnType,prefix,argList) \
\ \
/* Construct from argList function pointer type */ \ /* Function pointer type: construct from argList */ \
typedef autoPtr<baseType> (*argNames##ConstructorPtr)argList; \ typedef returnType (*prefix##Ptr)argList; \
\ \
/* Construct from argList function table type */ \ /* Function table type: construct from argList */ \
typedef HashTable \ typedef ::Foam::HashTable \
< \ < \
argNames##ConstructorPtr, \ prefix##Ptr, \
::Foam::word, \ ::Foam::word, \
::Foam::string::hasher \ ::Foam::string::hasher \
> argNames##ConstructorTable; \ > prefix##TableType; \
\ \
/* Construct from argList function pointer table pointer */ \ /* Lookup aliases for constructors */ \
static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \ typedef ::Foam::HashTable \
\
/* Table constructor called from the table add function */ \
static void construct##argNames##ConstructorTables(); \
\
/* Table destructor called from the table add function destructor */ \
static void destroy##argNames##ConstructorTables(); \
\
/* Class to add constructor from argList to table */ \
template<class baseType##Type> \
class add##argNames##ConstructorToTable \
{ \
public: \
\
static autoPtr<baseType> New argList \
{ \
return autoPtr<baseType>(new baseType##Type parList); \
} \
\
explicit add##argNames##ConstructorToTable \
( \
const ::Foam::word& lookup = baseType##Type::typeName \
) \
{ \
construct##argNames##ConstructorTables(); \
if (!argNames##ConstructorTablePtr_->insert(lookup, New)) \
{ \
std::cerr<< "Duplicate entry " << lookup \
<< " in runtime selection table " << #baseType \
<< std::endl; \
error::safePrintStack(std::cerr); \
} \
} \
\
~add##argNames##ConstructorToTable() \
{ \
destroy##argNames##ConstructorTables(); \
} \
\
add##argNames##ConstructorToTable \
(const add##argNames##ConstructorToTable&) = delete; \
\
void operator= \
(const add##argNames##ConstructorToTable&) = delete; \
}; \
\
/* Class to add constructor from argList to table */ \
/* Remove only the entry (not the table) upon destruction */ \
template<class baseType##Type> \
class addRemovable##argNames##ConstructorToTable \
{ \
public: \
\
const ::Foam::word name; /* Lookup name for later removal */ \
\
static autoPtr<baseType> New argList \
{ \
return autoPtr<baseType>(new baseType##Type parList); \
} \
\
explicit addRemovable##argNames##ConstructorToTable \
( \
const ::Foam::word& lookup = baseType##Type::typeName \
) \
: \
name(lookup) \
{ \
construct##argNames##ConstructorTables(); \
argNames##ConstructorTablePtr_->set(lookup, New); \
} \
\
~addRemovable##argNames##ConstructorToTable() \
{ \
if (argNames##ConstructorTablePtr_) \
{ \
argNames##ConstructorTablePtr_->erase(name); \
} \
} \
\
addRemovable##argNames##ConstructorToTable \
(const addRemovable##argNames##ConstructorToTable&) = delete; \
\
void operator= \
(const addRemovable##argNames##ConstructorToTable&) = delete; \
};
//- Declare a run-time selection for derived classes
#define declareRunTimeNewSelectionTable( \
autoPtr,baseType,argNames,argList,parList) \
\
/* Construct from argList function pointer type */ \
typedef autoPtr<baseType> (*argNames##ConstructorPtr)argList; \
\
/* Construct from argList function table type */ \
typedef HashTable \
< \ < \
argNames##ConstructorPtr, \ std::pair<::Foam::word,int>, \
::Foam::word, \ ::Foam::word, \
::Foam::string::hasher \ ::Foam::string::hasher \
> argNames##ConstructorTable; \ > prefix##CompatTableType; \
\ \
/* Construct from argList function pointer table pointer */ \ /* Table singleton (storage) */ \
static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \ static prefix##TableType* prefix##TablePtr_; \
\ \
/* Table constructor called from the table add function */ \ /* Lookup aliases singleton (storage) */ \
static void construct##argNames##ConstructorTables(); \ static std::unique_ptr<prefix##CompatTableType> prefix##CompatTablePtr_; \
\ \
/* Table destructor called from the table add function destructor */ \ /* Aliases singleton (access) */ \
static void destroy##argNames##ConstructorTables(); \ static prefix##CompatTableType& prefix##CompatTable(); \
\ \
/* Class to add constructor from argList to table */ \ /* Table construct/destruct helper */ \
template<class baseType##Type> \ static void prefix##TablePtr_construct(bool load); \
class add##argNames##ConstructorToTable \
{ \
public: \
\ \
static autoPtr<baseType> New##baseType argList \ /* Lookup function pointer from singleton, nullptr if not found */ \
{ \ static prefix##Ptr prefix##Table(const ::Foam::word& k)
return autoPtr<baseType>(baseType##Type::New parList.ptr()); \
} \
\
explicit add##argNames##ConstructorToTable \
( \
const ::Foam::word& lookup = baseType##Type::typeName \
) \
{ \
construct##argNames##ConstructorTables(); \
if \
( \
!argNames##ConstructorTablePtr_->insert \
( \
lookup, \
New##baseType \
) \
) \
{ \
std::cerr<< "Duplicate entry " << lookup \
<< " in runtime selection table " << #baseType \
<< std::endl; \
error::safePrintStack(std::cerr); \
} \
} \
\
~add##argNames##ConstructorToTable() \
{ \
destroy##argNames##ConstructorTables(); \
} \
\
add##argNames##ConstructorToTable \
(const add##argNames##ConstructorToTable&) = delete; \
\
void operator= \
(const add##argNames##ConstructorToTable&) = delete; \
}; \
\
/* Class to add constructor from argList to table */ \
template<class baseType##Type> \
class addRemovable##argNames##ConstructorToTable \
{ \
public: \
\
const ::Foam::word name; /* Lookup name for later removal */ \
\
static autoPtr<baseType> New##baseType argList \
{ \
return autoPtr<baseType>(baseType##Type::New parList.ptr()); \
} \
\
explicit addRemovable##argNames##ConstructorToTable \
( \
const ::Foam::word& lookup = baseType##Type::typeName \
) \
: \
name(lookup) \
{ \
construct##argNames##ConstructorTables(); \
argNames##ConstructorTablePtr_->set \
( \
lookup, \
New##baseType \
); \
} \
\
~addRemovable##argNames##ConstructorToTable() \
{ \
if (argNames##ConstructorTablePtr_) \
{ \
argNames##ConstructorTablePtr_->erase(name); \
} \
} \
\
addRemovable##argNames##ConstructorToTable \
(const addRemovable##argNames##ConstructorToTable&) = delete; \
\
void operator= \
(const addRemovable##argNames##ConstructorToTable&) = delete; \
};
// Constructor aid // Not used directly: storage and helper methods for runtime tables
#define defineRunTimeSelectionTableConstructor(baseType,argNames) \ #define defineRunTimeSelectionTableBase(baseType,prefix,Tspecialize) \
\ \
/* Table constructor called from the table add function */ \ /* Define table singleton (storage) */ \
void baseType::construct##argNames##ConstructorTables() \ Tspecialize prefix##TableType* prefix##TablePtr_(nullptr); \
\
/* Define aliases singleton (storage) */ \
Tspecialize \
std::unique_ptr<prefix##CompatTableType> prefix##CompatTablePtr_(nullptr); \
\
/* Define table singleton (access) for aliases */ \
Tspecialize prefix##CompatTableType& prefix##CompatTable() \
{ \
if (!prefix##CompatTablePtr_) \
{ \
prefix##CompatTablePtr_.reset(new prefix##CompatTableType(16)); \
} \
return *(prefix##CompatTablePtr_); \
} \
\
/* Table construct/destruct helper */ \
Tspecialize void prefix##TablePtr_construct(bool load) \
{ \ { \
static bool constructed = false; \ static bool constructed = false; \
if (load) \
{ \
if (!constructed) \ if (!constructed) \
{ \ { \
prefix##TablePtr_ = new prefix##TableType; \
constructed = true; \ constructed = true; \
baseType::argNames##ConstructorTablePtr_ \
= new baseType::argNames##ConstructorTable; \
} \ } \
}
// Destructor aid
#define defineRunTimeSelectionTableDestructor(baseType,argNames) \
\
/* Table destructor called from the table add function destructor */ \
void baseType::destroy##argNames##ConstructorTables() \
{ \
if (baseType::argNames##ConstructorTablePtr_) \
{ \
delete baseType::argNames##ConstructorTablePtr_; \
baseType::argNames##ConstructorTablePtr_ = nullptr; \
} \ } \
} else if (prefix##TablePtr_) \
{ \
delete prefix##TablePtr_; \
// Create pointer to hash-table of functions prefix##TablePtr_ = nullptr; \
#define defineRunTimeSelectionTablePtr(baseType,argNames) \ prefix##CompatTablePtr_.reset(nullptr); \
constructed = false; \
} \
} \
\ \
/* Define the constructor function table */ \ /* Define lookup function pointer (singleton) */ \
baseType::argNames##ConstructorTable* \ Tspecialize prefix##Ptr prefix##Table(const ::Foam::word& k) \
baseType::argNames##ConstructorTablePtr_(nullptr) { \
if (prefix##TablePtr_) \
{ \
const auto& tbl = *prefix##TablePtr_; \
auto iter = tbl.cfind(k); \
if (!iter.found() && prefix##CompatTablePtr_) \
{ \
const auto altIter = prefix##CompatTablePtr_->cfind(k); \
if (altIter.found()) \
{ \
const auto& alt = altIter.val(); /* <word,int> */ \
iter = tbl.cfind(alt.first); \
if (::Foam::error::warnAboutAge(alt.second)) \
{ \
std::cerr \
<< "Using [v" << alt.second << "] '" << k \
<< "' instead of '" << alt.first \
<< " in runtime selection table: " \
<< #baseType << '\n' << std::endl; \
::Foam::error::warnAboutAge("lookup", alt.second); \
} \
} \
} \
if (iter.found()) \
{ \
return iter.val(); \
} \
} \
return nullptr; \
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//
// Declaration Macros
//
//- Declare a run-time selection (variables and adder classes)
// The ptrWrapper is typically a Foam::autoPtr or a Foam::tmp container.
#define declareRunTimeSelectionTable\
(ptrWrapper,baseType,argNames,argList,parList) \
\
declareRunTimeSelectionTableBase( \
ptrWrapper<baseType>, argNames##Constructor, argList); \
\
/* Helper to add compatibility/alias for runtime selection table */ \
template<class baseType##Type> \
struct addAlias##argNames##ConstructorToTable \
{ \
explicit addAlias##argNames##ConstructorToTable \
( \
const ::Foam::word& k, \
const ::Foam::word& alias, \
const int ver \
) \
{ \
argNames##ConstructorCompatTable() \
.set(alias, std::pair<::Foam::word,int>(k,ver)); \
} \
}; \
\
/* Helper to add constructor from argList to table */ \
template<class baseType##Type> \
struct add##argNames##ConstructorToTable \
{ \
static ptrWrapper<baseType> New argList \
{ \
return ptrWrapper<baseType>(new baseType##Type parList); \
} \
\
explicit add##argNames##ConstructorToTable \
( \
const ::Foam::word& k = baseType##Type::typeName \
) \
{ \
argNames##ConstructorTablePtr_construct(true); \
if (!argNames##ConstructorTablePtr_->insert(k, New)) \
{ \
std::cerr \
<< "Duplicate entry " << k << " in runtime table " \
<< #baseType << std::endl; \
::Foam::error::safePrintStack(std::cerr); \
} \
} \
\
~add##argNames##ConstructorToTable() \
{ \
argNames##ConstructorTablePtr_construct(false); \
} \
\
add##argNames##ConstructorToTable \
(const add##argNames##ConstructorToTable&) = delete; \
\
void operator= \
(const add##argNames##ConstructorToTable&) = delete; \
}; \
\
/* Helper to add constructor from argList to table */ \
/* Remove only the entry (not the table) upon destruction */ \
template<class baseType##Type> \
struct addRemovable##argNames##ConstructorToTable \
{ \
const ::Foam::word name; /* Lookup name for later removal */ \
\
static ptrWrapper<baseType> New argList \
{ \
return ptrWrapper<baseType>(new baseType##Type parList); \
} \
\
explicit addRemovable##argNames##ConstructorToTable \
( \
const ::Foam::word& k = baseType##Type::typeName \
) \
: \
name(k) \
{ \
argNames##ConstructorTablePtr_construct(true); \
argNames##ConstructorTablePtr_->set(k, New); \
} \
\
~addRemovable##argNames##ConstructorToTable() \
{ \
if (argNames##ConstructorTablePtr_) \
{ \
argNames##ConstructorTablePtr_->erase(name); \
} \
} \
\
addRemovable##argNames##ConstructorToTable \
(const addRemovable##argNames##ConstructorToTable&) = delete; \
\
void operator= \
(const addRemovable##argNames##ConstructorToTable&) = delete; \
};
//- Declare a run-time selection for derived classes
#define declareRunTimeNewSelectionTable\
(ptrWrapper,baseType,argNames,argList,parList) \
\
declareRunTimeSelectionTableBase( \
ptrWrapper<baseType>,argNames##Constructor,argList); \
\
/* Helper to add compatibility/alias for runtime selection table */ \
template<class baseType##Type> \
struct addAlias##argNames##ConstructorToTable \
{ \
explicit addAlias##argNames##ConstructorToTable \
( \
const ::Foam::word& k, \
const ::Foam::word& alias, \
const int ver \
) \
{ \
argNames##ConstructorCompatTable() \
.set(alias, std::pair<::Foam::word,int>(k,ver)); \
} \
}; \
\
/* Helper to add constructor from argList to table */ \
template<class baseType##Type> \
struct add##argNames##ConstructorToTable \
{ \
static ptrWrapper<baseType> New##baseType argList \
{ \
return ptrWrapper<baseType>(baseType##Type::New parList.ptr()); \
} \
\
explicit add##argNames##ConstructorToTable \
( \
const ::Foam::word& k = baseType##Type::typeName \
) \
{ \
argNames##ConstructorTablePtr_construct(true); \
if (!argNames##ConstructorTablePtr_->insert(k, New##baseType)) \
{ \
std::cerr \
<< "Duplicate entry " << k << " in runtime table " \
<< #baseType << std::endl; \
::Foam::error::safePrintStack(std::cerr); \
} \
} \
\
~add##argNames##ConstructorToTable() \
{ \
argNames##ConstructorTablePtr_construct(false); \
} \
\
add##argNames##ConstructorToTable \
(const add##argNames##ConstructorToTable&) = delete; \
\
void operator= \
(const add##argNames##ConstructorToTable&) = delete; \
}; \
\
/* Helper to add constructor from argList to table */ \
template<class baseType##Type> \
struct addRemovable##argNames##ConstructorToTable \
{ \
const ::Foam::word name; /* Retain name for later removal */ \
\
static ptrWrapper<baseType> New##baseType argList \
{ \
return ptrWrapper<baseType>(baseType##Type::New parList.ptr()); \
} \
\
explicit addRemovable##argNames##ConstructorToTable \
( \
const ::Foam::word& k = baseType##Type::typeName \
) \
: \
name(k) \
{ \
argNames##ConstructorTablePtr_construct(true); \
argNames##ConstructorTablePtr_->set(k, New##baseType); \
} \
\
~addRemovable##argNames##ConstructorToTable() \
{ \
if (argNames##ConstructorTablePtr_) \
{ \
argNames##ConstructorTablePtr_->erase(name); \
} \
} \
\
addRemovable##argNames##ConstructorToTable \
(const addRemovable##argNames##ConstructorToTable&) = delete; \
\
void operator= \
(const addRemovable##argNames##ConstructorToTable&) = delete; \
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//
// Definition Macros
//
//- Define run-time selection table //- Define run-time selection table
#define defineRunTimeSelectionTable(baseType,argNames) \ #define defineRunTimeSelectionTable(baseType,argNames) \
\ \
defineRunTimeSelectionTablePtr(baseType,argNames); \ defineRunTimeSelectionTableBase( \
defineRunTimeSelectionTableConstructor(baseType,argNames); \ baseType,baseType::argNames##Constructor,)
defineRunTimeSelectionTableDestructor(baseType,argNames)
//- Define run-time selection table for template classes //- Define run-time selection table for template classes
// use when baseType doesn't need a template argument (eg, is a typedef) // use when baseType doesn't need a template argument (eg, is a typedef)
#define defineTemplateRunTimeSelectionTable(baseType,argNames) \ #define defineTemplateRunTimeSelectionTable(baseType,argNames) \
\ \
template<> \ defineRunTimeSelectionTableBase( \
defineRunTimeSelectionTablePtr(baseType,argNames); \ baseType,baseType::argNames##Constructor,template<>)
template<> \
defineRunTimeSelectionTableConstructor(baseType,argNames); \
template<> \
defineRunTimeSelectionTableDestructor(baseType,argNames)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Constructor aid: use when baseType requires the Targ template argument
#define defineTemplatedRunTimeSelectionTableConstructor(baseType,argNames,Targ)\
\
/* Table constructor called from the table add function */ \
void baseType<Targ>::construct##argNames##ConstructorTables() \
{ \
static bool constructed = false; \
if (!constructed) \
{ \
constructed = true; \
baseType<Targ>::argNames##ConstructorTablePtr_ \
= new baseType<Targ>::argNames##ConstructorTable; \
} \
}
// Destructor aid: use when baseType requires the Targ template argument
#define defineTemplatedRunTimeSelectionTableDestructor(baseType,argNames,Targ) \
\
/* Table destructor called from the table add function destructor */ \
void baseType<Targ>::destroy##argNames##ConstructorTables() \
{ \
if (baseType<Targ>::argNames##ConstructorTablePtr_) \
{ \
delete baseType<Targ>::argNames##ConstructorTablePtr_; \
baseType<Targ>::argNames##ConstructorTablePtr_ = nullptr; \
} \
}
//- Create pointer to hash-table of functions
// use when baseType requires the Targ template argument
#define defineTemplatedRunTimeSelectionTablePtr(baseType,argNames,Targ) \
\
/* Define the constructor function table */ \
baseType<Targ>::argNames##ConstructorTable* \
baseType<Targ>::argNames##ConstructorTablePtr_(nullptr)
//- Define run-time selection table for template classes //- Define run-time selection table for template classes
// use when baseType requires the Targ template argument // use when baseType requires the Targ template argument
#define defineTemplatedRunTimeSelectionTable(baseType,argNames,Targ) \ #define defineTemplatedRunTimeSelectionTable(baseType,argNames,Targ) \
\ \
template<> \ defineRunTimeSelectionTableBase( \
defineTemplatedRunTimeSelectionTablePtr(baseType,argNames,Targ); \ baseType,baseType<Targ>::argNames##Constructor,template<>)
template<> \
defineTemplatedRunTimeSelectionTableConstructor(baseType,argNames,Targ); \
template<> \
defineTemplatedRunTimeSelectionTableDestructor(baseType,argNames,Targ)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -29,6 +30,10 @@ InClass
Description Description
Macros for easy insertion into member function selection tables Macros for easy insertion into member function selection tables
Note
The helper macro names used here must remain synchronized with
definitions in memberFunctionSelectionTables.H
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef addToMemberFunctionSelectionTable_H #ifndef addToMemberFunctionSelectionTable_H
@ -36,99 +41,103 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Add to hash-table of functions with typeName as the key.
// add to hash-table of functions with typename as the key
#define addToMemberFunctionSelectionTable\ #define addToMemberFunctionSelectionTable\
(baseType,thisType,memberFunction,argNames) \ (baseType,thisType,funcName,argNames) \
\ \
/* Add the thisType memberFunction to the table */ \ /* Add thisType funcName to the table */ \
baseType::add##memberFunction##argNames##MemberFunctionToTable<thisType> \ baseType::add##funcName##argNames##MemberFunctionToTable<thisType> \
add##thisType##memberFunction##argNames##MemberFunctionTo##baseType##Table_ add##thisType##funcName##argNames##MemberFunctionTo##baseType##Table_
//- Add to hash-table of functions with 'lookupName' as the key.
// add to hash-table of functions with 'lookup' as the key
#define addNamedToMemberFunctionSelectionTable\ #define addNamedToMemberFunctionSelectionTable\
(baseType,thisType,memberFunction,argNames,lookup) \ (baseType,thisType,funcName,argNames,lookupName) \
\ \
/* Add the thisType memberFunction to the table, find by lookup name */ \ /* Add thisType funcName to the table, find by lookup name */ \
baseType::add##memberFunction##argNames##MemberFunctionToTable<thisType> \ baseType::add##funcName##argNames##MemberFunctionToTable<thisType> \
add_##lookup##_##thisType##memberFunction##argNames##MemberFunctionTo## \ add##thisType##funcName##argNames##MemberFunctionTo## \
baseType##Table_(#lookup) baseType##Table_##lookupName##_(#lookupName)
//- Add lookup alias for runTime member selection.
#define addAliasToMemberFunctionSelectionTable\
(baseType,thisType,funcName,argNames,lookup,other,ver) \
\
/* Add thisType funcName to the table, find by lookup name */ \
baseType::addAlias##funcName##argNames##MemberFunctionToTable<thisType> \
add##thisType##funcName##argNames##MemberFunctionTo##baseType##Table_ \
##lookup##_##other##_(#lookup,#other,ver)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Add to hash-table of functions with typeName as the key.
// add to hash-table of functions with typename as the key // Use when baseType doesn't need a template argument (eg, is a typedef)
// use when baseType doesn't need a template argument (eg, is a typedef)
#define addTemplateToMemberFunctionSelectionTable\ #define addTemplateToMemberFunctionSelectionTable\
(baseType,thisType,Targ,memberFunction,argNames) \ (baseType,thisType,Targ,funcName,argNames) \
\ \
/* Add the thisType memberFunction to the table */ \ /* Add thisType funcName to the table */ \
baseType::add##memberFunction##argNames## \ baseType::add##funcName##argNames##MemberFunctionToTable<thisType<Targ>> \
MemberFunctionToTable<thisType<Targ>> \ add##thisType##Targ##funcName##argNames##MemberFunctionTo## \
add##thisType##Targ##memberFunction##argNames##MemberFunctionTo## \
baseType##Table_ baseType##Table_
// add to hash-table of functions with 'lookup' as the key //- Add to hash-table of functions with 'lookupName' as the key.
// use when baseType doesn't need a template argument (eg, is a typedef) // Use when baseType doesn't need a template argument (eg, is a typedef)
#define addNamedTemplateToMemberFunctionSelectionTable\ #define addNamedTemplateToMemberFunctionSelectionTable\
(baseType,thisType,Targ,memberFunction,argNames,lookup) \ (baseType,thisType,Targ,funcName,argNames,lookupName) \
\ \
/* Add the thisType memberFunction to the table, find by lookup name */ \ /* Add thisType funcName to the table, find by lookupName */ \
baseType::add##memberFunction##argNames## \ baseType::add##funcName##argNames##MemberFunctionToTable<thisType<Targ>> \
MemberFunctionToTable<thisType<Targ>> \ add##thisType##Targ##funcName##argNames##MemberFunctionTo## \
add_##lookup##_##thisType##Targ##memberFunction##argNames## \ baseType##Table_##lookupName##_(#lookupName)
MemberFunctionTo##baseType##Table_(#lookup)
// use when baseType requires the Targ template argument as well
#define addTemplatedToMemberFunctionSelectionTable\
(baseType,thisType,Targ,memberFunction,argNames) \
\
/* Add the thisType memberFunction to the table */ \
baseType<Targ>::add##memberFunction##argNames## \
MemberFunctionToTable<thisType<Targ>> \
add##thisType##Targ##memberFunction##argNames##MemberFunctionTo## \
baseType##Targ##Table_
// use when baseType requires the Targ template argument as well //- Add lookup alias for runTime member selection.
#define addNamedTemplatedToMemberFunctionSelectionTable\ #define addAliasTemplateToMemberFunctionSelectionTable\
(baseType,thisType,Targ,memberFunction,argNames,lookup) \ (baseType,thisType,Targ,funcName,argNames,lookup,other,ver) \
\ \
/* Add the thisType memberFunction to the table, find by lookup name */ \ /* Add thisType funcName to the table, find by lookup name */ \
baseType<Targ>::add##memberFunction##argNames## \ baseType::addAlias##funcName##argNames##MemberFunctionToTable \
MemberFunctionToTable<thisType<Targ>> \ <thisType<Targ>> \
add_##lookup##_##thisType##Targ##memberFunction##argNames## \ add##thisType##Targ##funcName##argNames##MemberFunctionTo##baseType \
MemberFunctionTo##baseType##Targ##Table_(#lookup) ##lookup##_##other##_(#lookup,#other,ver)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Add to hash-table of functions with typeName as the key.
// add to hash-table of functions with typename as the key // Use when baseType requires the Targ template argument as well
// use when baseType requires the Targ template argument as well
#define addTemplatedToMemberFunctionSelectionTable\ #define addTemplatedToMemberFunctionSelectionTable\
(baseType,thisType,Targ,memberFunction,argNames) \ (baseType,thisType,Targ,funcName,argNames) \
\ \
/* Add the thisType memberFunction to the table */ \ /* Add thisType funcName to the table */ \
baseType<Targ>::add##memberFunction##argNames## \ baseType<Targ>::add##funcName##argNames##MemberFunctionToTable \
MemberFunctionToTable<thisType<Targ>> \ <thisType<Targ>> \
add##thisType##Targ##memberFunction##argNames##MemberFunctionTo## \ add##thisType##Targ##funcName##argNames##MemberFunctionTo## \
baseType##Targ##Table_ baseType##Targ##Table_
//- Add to hash-table of functions with 'lookupName' as the key.
// add to hash-table of functions with 'lookup' as the key // Use when baseType requires the Targ template argument as well
// use when baseType requires the Targ template argument as well
#define addNamedTemplatedToMemberFunctionSelectionTable\ #define addNamedTemplatedToMemberFunctionSelectionTable\
(baseType,thisType,Targ,memberFunction,argNames,lookup) \ (baseType,thisType,Targ,funcName,argNames,lookupName) \
\ \
/* Add the thisType memberFunction to the table, find by lookup name */ \ /* Add thisType funcName to the table, find by lookupName */ \
baseType<Targ>::add##memberFunction##argNames## \ baseType<Targ>::add##funcName##argNames##MemberFunctionToTable \
MemberFunctionToTable<thisType<Targ>> \ <thisType<Targ>> \
add_##lookup##_##thisType##Targ##memberFunction##argNames## \ add##thisType##Targ##funcName##argNames##MemberFunctionTo## \
MemberFunctionTo##baseType##Targ##Table_(#lookup) baseType##Targ##Table_##lookupName##_(#lookupName)
//- Add lookup alias for runTime member selection.
#define addAliasTemplatedToMemberFunctionSelectionTable\
(baseType,thisType,Targ,funcName,argNames,lookup,other,ver) \
\
/* Add thisType funcName to the table, find by lookup name */ \
baseType<Targ>::addAlias##funcName##argNames##MemberFunctionToTable \
<thisType<Targ>> \
add##thisType##Targ##funcName##argNames##MemberFunctionTo##baseType## \
Targ##Table_##lookup##_##other##_(#lookup,#other,ver)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -25,206 +25,146 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description Description
Macros to enable the easy declaration of member function selection tables. Macros to ease declaration of member function selection tables.
Note
Uses macros from runTimeSelectionTables.H
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "token.H"
#ifndef memberFunctionSelectionTables_H #ifndef memberFunctionSelectionTables_H
#define memberFunctionSelectionTables_H #define memberFunctionSelectionTables_H
#include "HashTable.H" #include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Declare a run-time selection: //
#define declareMemberFunctionSelectionTable( \ // Declaration Macros
returnType,baseType,memberFunction,argNames,argList,parList) \ //
//- Declare a run-time member-function selection (variables and adder classes)
#define declareMemberFunctionSelectionTable\
(returnType,baseType,funcName,argNames,argList,parListUnused) \
\ \
/* Construct from argList function pointer type */ \ declareRunTimeSelectionTableBase( \
typedef returnType (*memberFunction##argNames##MemberFunctionPtr)argList; \ returnType, funcName##argNames##MemberFunction, argList); \
\ \
/* Construct from argList function table type */ \ /* Helper to add funcName to table */ \
typedef HashTable \
< \
memberFunction##argNames##MemberFunctionPtr, \
::Foam::word, \
::Foam::string::hasher \
> memberFunction##argNames##MemberFunctionTable; \
\
/* Construct from argList function pointer table pointer */ \
static memberFunction##argNames##MemberFunctionTable* \
memberFunction##argNames##MemberFunctionTablePtr_; \
\
/* Class to add constructor from argList to table */ \
template<class baseType##Type> \ template<class baseType##Type> \
class add##memberFunction##argNames##MemberFunctionToTable \ struct add##funcName##argNames##MemberFunctionToTable \
{ \ { \
public: \ explicit add##funcName##argNames##MemberFunctionToTable \
\
explicit add##memberFunction##argNames##MemberFunctionToTable \
( \ ( \
const ::Foam::word& lookup = baseType##Type::typeName \ const ::Foam::word& k = baseType##Type::typeName \
) \ ) \
{ \ { \
construct##memberFunction##argNames##MemberFunctionTables(); \ funcName##argNames##MemberFunctionTablePtr_construct(true); \
memberFunction##argNames##MemberFunctionTablePtr_->insert \ if \
( \ ( \
lookup, \ !funcName##argNames##MemberFunctionTablePtr_ \
baseType##Type::memberFunction \ ->insert(k, baseType##Type::funcName) \
); \ ) \
{ \
std::cerr \
<< "Duplicate entry " << k << " in member table " \
<< #baseType << std::endl; \
::Foam::error::safePrintStack(std::cerr); \
} \
} \ } \
\ \
~add##memberFunction##argNames##MemberFunctionToTable() \ ~add##funcName##argNames##MemberFunctionToTable() \
{ \ { \
destroy##memberFunction##argNames##MemberFunctionTables(); \ funcName##argNames##MemberFunctionTablePtr_construct(false); \
} \ } \
\
add##funcName##argNames##MemberFunctionToTable \
(const add##funcName##argNames##MemberFunctionToTable&) \
= delete; \
void operator= \
(const add##funcName##argNames##MemberFunctionToTable&) \
= delete; \
}; \ }; \
\ \
/* Table memberFunction called from the table add function */ \ /* Helper to add funcName to table */ \
static void construct##memberFunction##argNames##MemberFunctionTables(); \ template<class baseType##Type> \
\ struct addRemovable##funcName##argNames##MemberFunctionToTable \
/* Table destructor called from the table add function destructor */ \
static void destroy##memberFunction##argNames##MemberFunctionTables()
// Constructor aid
#define defineMemberFunctionSelectionTableMemberFunction( \
baseType,memberFunction,argNames) \
\
/* Table memberFunction called from the table add function */ \
void baseType::construct##memberFunction##argNames##MemberFunctionTables() \
{ \ { \
static bool constructed = false; \ const ::Foam::word name; /* Retain name for later removal */ \
if (!constructed) \ \
explicit addRemovable##funcName##argNames##MemberFunctionToTable \
( \
const ::Foam::word& k = baseType##Type::typeName \
) \
: \
name(k) \
{ \ { \
constructed = true; \ funcName##argNames##MemberFunctionTablePtr_construct(true); \
baseType::memberFunction##argNames##MemberFunctionTablePtr_ \ funcName##argNames##MemberFunctionTablePtr_ \
= new baseType::memberFunction##argNames##MemberFunctionTable; \ ->set(k, baseType##Type::funcName); \
} \ } \
}
// Destructor aid
#define defineMemberFunctionSelectionTableDestructor( \
baseType,memberFunction,argNames) \
\ \
/* Table destructor called from the table add function destructor */ \ ~addRemovable##funcName##argNames##MemberFunctionToTable() \
void baseType::destroy##memberFunction##argNames##MemberFunctionTables() \
{ \ { \
if (baseType::memberFunction##argNames##MemberFunctionTablePtr_) \ if (funcName##argNames##MemberFunctionTablePtr_) \
{ \ { \
delete baseType::memberFunction##argNames## \ funcName##argNames##MemberFunctionTablePtr_->erase(name); \
MemberFunctionTablePtr_; \ } \
baseType::memberFunction##argNames## \
MemberFunctionTablePtr_ = nullptr; \
} \ } \
}
// Create pointer to hash-table of functions
#define defineMemberFunctionSelectionTablePtr(baseType,memberFunction,argNames)\
\ \
/* Define the memberFunction table */ \ addRemovable##funcName##argNames##MemberFunctionToTable \
baseType::memberFunction##argNames##MemberFunctionTable* \ (const addRemovable##funcName##argNames##MemberFunctionToTable&) \
baseType::memberFunction##argNames##MemberFunctionTablePtr_(nullptr) = delete; \
void operator= \
(const addRemovable##funcName##argNames##MemberFunctionToTable&) \
= delete; \
}; \
\
/* Helper to add alias for funcName to table */ \
template<class baseType##Type> \
struct addAlias##funcName##argNames##MemberFunctionToTable \
{ \
explicit addAlias##funcName##argNames##MemberFunctionToTable \
( \
const ::Foam::word& k, \
const ::Foam::word& alias, \
const int ver \
) \
{ \
funcName##argNames##MemberFunctionCompatTable() \
.set(alias, std::pair<::Foam::word,int>(k,ver)); \
} \
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//
// Definition Macros
//
//- Define run-time selection table //- Define run-time selection table
#define defineMemberFunctionSelectionTable(baseType,memberFunction,argNames) \ #define defineMemberFunctionSelectionTable(baseType,funcName,argNames) \
\ \
defineMemberFunctionSelectionTablePtr \ defineRunTimeSelectionTableBase( \
(baseType,memberFunction,argNames); \ baseType,baseType::funcName##argNames##MemberFunction,)
defineMemberFunctionSelectionTableMemberFunction \
(baseType,memberFunction,argNames) \
defineMemberFunctionSelectionTableDestructor \
(baseType,memberFunction,argNames)
//- Define run-time selection table for template classes //- Define run-time selection table for template classes
// use when baseType doesn't need a template argument (eg, is a typedef) // use when baseType doesn't need a template argument (eg, is a typedef)
#define defineTemplateMemberFunctionSelectionTable( \ #define defineTemplateMemberFunctionSelectionTable(baseType,funcName,argNames) \
baseType,memberFunction,argNames) \
\ \
template<> \ defineRunTimeSelectionTableBase( \
defineMemberFunctionSelectionTablePtr \ baseType,baseType::funcName##argNames##MemberFunction,template<>)
(baseType,memberFunction,argNames); \
template<> \
defineMemberFunctionSelectionTableMemberFunction \
(baseType,memberFunction,argNames) \
template<> \
defineMemberFunctionSelectionTableDestructor \
(baseType,memberFunction,argNames)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Constructor aid: use when baseType requires the Targ template argument
#define defineTemplatedMemberFunctionSelectionTableMemberFunction( \
baseType,memberFunction,argNames,Targ) \
\
/* Table memberFunction called from the table add function */ \
void baseType<Targ>::construct##memberFunction##argNames## \
MemberFunctionTables() \
{ \
static bool constructed = false; \
if (!constructed) \
{ \
constructed = true; \
baseType<Targ>::memberFunction##argNames##MemberFunctionTablePtr_ \
= new baseType<Targ>::memberFunction##argNames## \
MemberFunctionTable; \
} \
}
// Destructor aid
// use when baseType requires the Targ template argument
#define defineTemplatedMemberFunctionSelectionTableDestructor( \
baseType,memberFunction,argNames,Targ) \
\
/* Table destructor called from the table add function destructor */ \
void baseType<Targ>::destroy##memberFunction##argNames## \
MemberFunctionTables() \
{ \
if (baseType<Targ>::memberFunction##argNames##MemberFunctionTablePtr_) \
{ \
delete baseType<Targ>::memberFunction##argNames## \
MemberFunctionTablePtr_; \
baseType<Targ>::memberFunction##argNames## \
MemberFunctionTablePtr_ = nullptr; \
} \
}
// Create pointer to hash-table of functions
// use when baseType requires the Targ template argument
#define defineTemplatedMemberFunctionSelectionTablePtr( \
baseType,memberFunction,argNames,Targ) \
\
/* Define the memberFunction table */ \
baseType<Targ>::memberFunction##argNames##MemberFunctionTable* \
baseType<Targ>::memberFunction##argNames## \
MemberFunctionTablePtr_(nullptr)
//- Define run-time selection table for template classes //- Define run-time selection table for template classes
// use when baseType requires the Targ template argument // use when baseType requires the Targ template argument
#define defineTemplatedMemberFunctionSelectionTable( \ #define defineTemplatedMemberFunctionSelectionTable\
baseType,memberFunction,argNames,Targ) \ (baseType,funcName,argNames,Targ) \
\ \
template<> \ defineRunTimeSelectionTableBase( \
defineTemplatedMemberFunctionSelectionTablePtr \ baseType,baseType<Targ>::funcName##argNames##MemberFunction,template<>)
(baseType,memberFunction,argNames,Targ); \
template<> \
defineTemplatedMemberFunctionSelectionTableMemberFunction \
(baseType,memberFunction,argNames,Targ) \
template<> \
defineTemplatedMemberFunctionSelectionTableDestructor \
(baseType,memberFunction,argNames,Targ)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Original code Copyright (C) 2014-2018 Bernhard Gschaider Original code Copyright (C) 2014-2018 Bernhard Gschaider
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -119,9 +119,9 @@ Foam::exprTools::expressionEntry::New
const word& name const word& name
) )
{ {
auto cstrIter = emptyConstructorTablePtr_->cfind(name); auto* ctorPtr = emptyConstructorTable(name);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInLookup FatalErrorInLookup
( (
@ -131,7 +131,7 @@ Foam::exprTools::expressionEntry::New
) << exit(FatalError); ) << exit(FatalError);
} }
return autoPtr<expressionEntry>(cstrIter()()); return autoPtr<expressionEntry>(ctorPtr());
} }

View File

@ -314,9 +314,9 @@ Foam::expressions::exprResult::New
if (dict.getOrDefault("unsetValue", false)) if (dict.getOrDefault("unsetValue", false))
{ {
auto cstrIter = emptyConstructorTablePtr_->cfind(resultType); auto* ctorPtr = emptyConstructorTable(resultType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -330,13 +330,13 @@ Foam::expressions::exprResult::New
DebugInfo DebugInfo
<< "Creating unset result of type " << resultType << nl; << "Creating unset result of type " << resultType << nl;
return autoPtr<exprResult>(cstrIter()()); return autoPtr<exprResult>(ctorPtr());
} }
auto cstrIter = dictionaryConstructorTablePtr_->cfind(resultType); auto* ctorPtr = dictionaryConstructorTable(resultType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -350,7 +350,7 @@ Foam::expressions::exprResult::New
DebugInfo DebugInfo
<< "Creating result of type " << resultType << nl; << "Creating result of type " << resultType << nl;
return autoPtr<exprResult>(cstrIter()(dict)); return autoPtr<exprResult>(ctorPtr(dict));
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -93,14 +94,13 @@ Foam::pointPatchField<Type>::NewCalculatedType
const pointPatchField<Type2>& pf const pointPatchField<Type2>& pf
) )
{ {
auto patchTypeCstrIter = auto* patchTypeCtor = pointPatchConstructorTable(pf.patch().type());
pointPatchConstructorTablePtr_->cfind(pf.patch().type());
if (patchTypeCstrIter.found()) if (patchTypeCtor)
{ {
return autoPtr<pointPatchField<Type>> return autoPtr<pointPatchField<Type>>
( (
patchTypeCstrIter() patchTypeCtor
( (
pf.patch(), pf.patch(),
Field<Type>::null() Field<Type>::null()

View File

@ -39,9 +39,9 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
{ {
DebugInFunction << "Constructing pointPatchField<Type>" << endl; DebugInFunction << "Constructing pointPatchField<Type>" << endl;
auto cstrIter = pointPatchConstructorTablePtr_->cfind(patchFieldType); auto* ctorPtr = pointPatchConstructorTable(patchFieldType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInLookup FatalErrorInLookup
( (
@ -51,7 +51,7 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
) << exit(FatalError); ) << exit(FatalError);
} }
autoPtr<pointPatchField<Type>> pfPtr(cstrIter()(p, iF)); autoPtr<pointPatchField<Type>> pfPtr(ctorPtr(p, iF));
if if
( (
@ -64,10 +64,9 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
// Incompatible (constraint-wise) with the patch type // Incompatible (constraint-wise) with the patch type
// - use default constraint type // - use default constraint type
auto patchTypeCstrIter = auto* patchTypeCtor = pointPatchConstructorTable(p.type());
pointPatchConstructorTablePtr_->cfind(p.type());
if (!patchTypeCstrIter.found()) if (!patchTypeCtor)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Inconsistent patch and patchField types for\n" << "Inconsistent patch and patchField types for\n"
@ -76,7 +75,7 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
<< exit(FatalError); << exit(FatalError);
} }
return patchTypeCstrIter()(p, iF); return patchTypeCtor(p, iF);
} }
} }
else else
@ -115,16 +114,16 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
const word patchFieldType(dict.get<word>("type")); const word patchFieldType(dict.get<word>("type"));
auto cstrIter = dictionaryConstructorTablePtr_->cfind(patchFieldType); auto* ctorPtr = dictionaryConstructorTable(patchFieldType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
if (!disallowGenericPointPatchField) if (!disallowGenericPointPatchField)
{ {
cstrIter = dictionaryConstructorTablePtr_->cfind("generic"); ctorPtr = dictionaryConstructorTable("generic");
} }
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInFunction(dict) FatalIOErrorInFunction(dict)
<< "Unknown patchField type " << patchFieldType << "Unknown patchField type " << patchFieldType
@ -136,7 +135,7 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
} }
// Construct (but not necessarily returned) // Construct (but not necessarily returned)
autoPtr<pointPatchField<Type>> pfPtr(cstrIter()(p, iF, dict)); autoPtr<pointPatchField<Type>> pfPtr(ctorPtr(p, iF, dict));
if if
( (
@ -149,10 +148,9 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
// Incompatible (constraint-wise) with the patch type // Incompatible (constraint-wise) with the patch type
// - use default constraint type // - use default constraint type
auto patchTypeCstrIter = auto* patchTypeCtor = dictionaryConstructorTable(p.type());
dictionaryConstructorTablePtr_->cfind(p.type());
if (!patchTypeCstrIter.found()) if (!patchTypeCtor)
{ {
FatalIOErrorInFunction(dict) FatalIOErrorInFunction(dict)
<< "Inconsistent patch and patchField types for\n" << "Inconsistent patch and patchField types for\n"
@ -161,7 +159,7 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
<< exit(FatalIOError); << exit(FatalIOError);
} }
return patchTypeCstrIter()(p, iF, dict); return patchTypeCtor(p, iF, dict);
} }
} }
@ -180,9 +178,9 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
{ {
DebugInFunction << "Constructing pointPatchField<Type>" << endl; DebugInFunction << "Constructing pointPatchField<Type>" << endl;
auto cstrIter = patchMapperConstructorTablePtr_->cfind(ptf.type()); auto* ctorPtr = patchMapperConstructorTable(ptf.type());
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInLookup FatalErrorInLookup
( (
@ -192,7 +190,7 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
) << exit(FatalError); ) << exit(FatalError);
} }
return cstrIter()(ptf, p, iF, pfMapper); return ctorPtr(ptf, p, iF, pfMapper);
} }

View File

@ -571,6 +571,7 @@ Foam::word Foam::argList::optionCompat(const word& optName)
{ {
const auto& alt = fnd.val(); const auto& alt = fnd.val();
// No error::master() guard - only called on master anyhow
if (error::warnAboutAge(alt.second)) if (error::warnAboutAge(alt.second))
{ {
std::cerr std::cerr
@ -609,6 +610,7 @@ int Foam::argList::optionIgnore(const word& optName)
// '-option ARG' or '-option' // '-option ARG' or '-option'
const int nskip = (alt.first ? 2 : 1); const int nskip = (alt.first ? 2 : 1);
// No error::master() guard - only called on master anyhow
if (error::warnAboutAge(alt.second)) if (error::warnAboutAge(alt.second))
{ {
std::cerr std::cerr

View File

@ -711,9 +711,9 @@ Foam::fileOperation::New
DebugInFunction DebugInFunction
<< "Constructing fileHandler" << endl; << "Constructing fileHandler" << endl;
auto cstrIter = wordConstructorTablePtr_->cfind(handlerType); auto* ctorPtr = wordConstructorTable(handlerType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInLookup FatalErrorInLookup
( (
@ -723,7 +723,7 @@ Foam::fileOperation::New
) << abort(FatalError); ) << abort(FatalError);
} }
return autoPtr<fileOperation>(cstrIter()(verbose)); return autoPtr<fileOperation>(ctorPtr(verbose));
} }

View File

@ -85,9 +85,9 @@ Foam::fileOperations::fileOperationInitialise::New
{ {
DebugInFunction << "Constructing fileOperationInitialise" << endl; DebugInFunction << "Constructing fileOperationInitialise" << endl;
auto cstrIter = wordConstructorTablePtr_->cfind(type); auto* ctorPtr = wordConstructorTable(type);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInLookup FatalErrorInLookup
( (
@ -97,7 +97,7 @@ Foam::fileOperations::fileOperationInitialise::New
) << abort(FatalError); ) << abort(FatalError);
} }
return autoPtr<fileOperationInitialise>(cstrIter()(argc, argv)); return autoPtr<fileOperationInitialise>(ctorPtr(argc, argv));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -219,9 +219,9 @@ Foam::autoPtr<Foam::graph::writer> Foam::graph::writer::New
<< exit(FatalError); << exit(FatalError);
} }
auto cstrIter = wordConstructorTablePtr_->cfind(graphFormat); auto* ctorPtr = wordConstructorTable(graphFormat);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInLookup FatalErrorInLookup
( (
@ -231,7 +231,7 @@ Foam::autoPtr<Foam::graph::writer> Foam::graph::writer::New
) << exit(FatalError); ) << exit(FatalError);
} }
return autoPtr<graph::writer>(cstrIter()()); return autoPtr<graph::writer>(ctorPtr());
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -42,9 +42,9 @@ Foam::autoPtr<Foam::tableReader<Type>> Foam::tableReader<Type>::New
"openFoam" "openFoam"
); );
auto cstrIter = dictionaryConstructorTablePtr_->cfind(readerType); auto* ctorPtr = dictionaryConstructorTable(readerType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -55,7 +55,7 @@ Foam::autoPtr<Foam::tableReader<Type>> Foam::tableReader<Type>::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<tableReader<Type>>(cstrIter()(spec)); return autoPtr<tableReader<Type>>(ctorPtr(spec));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -57,9 +57,9 @@ Foam::autoPtr<Foam::interpolationWeights> Foam::interpolationWeights::New
{ {
DebugInFunction << "Selecting interpolationWeights " << type << endl; DebugInFunction << "Selecting interpolationWeights " << type << endl;
auto cstrIter = wordConstructorTablePtr_->cfind(type); auto* ctorPtr = wordConstructorTable(type);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInLookup FatalErrorInLookup
( (
@ -69,7 +69,7 @@ Foam::autoPtr<Foam::interpolationWeights> Foam::interpolationWeights::New
) << exit(FatalError); ) << exit(FatalError);
} }
return autoPtr<interpolationWeights>(cstrIter()(samples)); return autoPtr<interpolationWeights>(ctorPtr(samples));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -45,10 +45,9 @@ Foam::LduMatrix<Type, DType, LUType>::preconditioner::New
if (sol.matrix().symmetric()) if (sol.matrix().symmetric())
{ {
auto cstrIter = auto* ctorPtr = symMatrixConstructorTable(preconditionerName);
symMatrixConstructorTablePtr_->cfind(preconditionerName);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -61,7 +60,7 @@ Foam::LduMatrix<Type, DType, LUType>::preconditioner::New
return autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner> return autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner>
( (
cstrIter() ctorPtr
( (
sol, sol,
preconditionerDict preconditionerDict
@ -70,10 +69,9 @@ Foam::LduMatrix<Type, DType, LUType>::preconditioner::New
} }
else if (sol.matrix().asymmetric()) else if (sol.matrix().asymmetric())
{ {
auto cstrIter = auto* ctorPtr = asymMatrixConstructorTable(preconditionerName);
asymMatrixConstructorTablePtr_->cfind(preconditionerName);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -86,7 +84,7 @@ Foam::LduMatrix<Type, DType, LUType>::preconditioner::New
return autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner> return autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner>
( (
cstrIter() ctorPtr
( (
sol, sol,
preconditionerDict preconditionerDict

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -43,9 +43,9 @@ Foam::LduMatrix<Type, DType, LUType>::smoother::New
if (matrix.symmetric()) if (matrix.symmetric())
{ {
auto cstrIter = symMatrixConstructorTablePtr_->cfind(smootherName); auto* ctorPtr = symMatrixConstructorTable(smootherName);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -58,7 +58,7 @@ Foam::LduMatrix<Type, DType, LUType>::smoother::New
return autoPtr<typename LduMatrix<Type, DType, LUType>::smoother> return autoPtr<typename LduMatrix<Type, DType, LUType>::smoother>
( (
cstrIter() ctorPtr
( (
fieldName, fieldName,
matrix matrix
@ -67,9 +67,9 @@ Foam::LduMatrix<Type, DType, LUType>::smoother::New
} }
else if (matrix.asymmetric()) else if (matrix.asymmetric())
{ {
auto cstrIter = asymMatrixConstructorTablePtr_->cfind(smootherName); auto* ctorPtr = asymMatrixConstructorTable(smootherName);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -82,7 +82,7 @@ Foam::LduMatrix<Type, DType, LUType>::smoother::New
return autoPtr<typename LduMatrix<Type, DType, LUType>::smoother> return autoPtr<typename LduMatrix<Type, DType, LUType>::smoother>
( (
cstrIter() ctorPtr
( (
fieldName, fieldName,
matrix matrix

View File

@ -56,9 +56,9 @@ Foam::LduMatrix<Type, DType, LUType>::solver::New
} }
else if (matrix.symmetric()) else if (matrix.symmetric())
{ {
auto cstrIter = symMatrixConstructorTablePtr_->cfind(solverName); auto* ctorPtr = symMatrixConstructorTable(solverName);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -71,7 +71,7 @@ Foam::LduMatrix<Type, DType, LUType>::solver::New
return autoPtr<typename LduMatrix<Type, DType, LUType>::solver> return autoPtr<typename LduMatrix<Type, DType, LUType>::solver>
( (
cstrIter() ctorPtr
( (
fieldName, fieldName,
matrix, matrix,
@ -81,9 +81,9 @@ Foam::LduMatrix<Type, DType, LUType>::solver::New
} }
else if (matrix.asymmetric()) else if (matrix.asymmetric())
{ {
auto cstrIter = asymMatrixConstructorTablePtr_->cfind(solverName); auto* ctorPtr = asymMatrixConstructorTable(solverName);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -96,7 +96,7 @@ Foam::LduMatrix<Type, DType, LUType>::solver::New
return autoPtr<typename LduMatrix<Type, DType, LUType>::solver> return autoPtr<typename LduMatrix<Type, DType, LUType>::solver>
( (
cstrIter() ctorPtr
( (
fieldName, fieldName,
matrix, matrix,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -90,9 +90,9 @@ Foam::lduMatrix::preconditioner::New
if (sol.matrix().symmetric()) if (sol.matrix().symmetric())
{ {
auto cstrIter = symMatrixConstructorTablePtr_->cfind(name); auto* ctorPtr = symMatrixConstructorTable(name);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -105,7 +105,7 @@ Foam::lduMatrix::preconditioner::New
return autoPtr<lduMatrix::preconditioner> return autoPtr<lduMatrix::preconditioner>
( (
cstrIter() ctorPtr
( (
sol, sol,
controls controls
@ -114,9 +114,9 @@ Foam::lduMatrix::preconditioner::New
} }
else if (sol.matrix().asymmetric()) else if (sol.matrix().asymmetric())
{ {
auto cstrIter = asymMatrixConstructorTablePtr_->cfind(name); auto* ctorPtr = asymMatrixConstructorTable(name);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -129,7 +129,7 @@ Foam::lduMatrix::preconditioner::New
return autoPtr<lduMatrix::preconditioner> return autoPtr<lduMatrix::preconditioner>
( (
cstrIter() ctorPtr
( (
sol, sol,
controls controls

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -93,9 +93,9 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
if (matrix.symmetric()) if (matrix.symmetric())
{ {
auto cstrIter = symMatrixConstructorTablePtr_->cfind(name); auto* ctorPtr = symMatrixConstructorTable(name);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -108,7 +108,7 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
return autoPtr<lduMatrix::smoother> return autoPtr<lduMatrix::smoother>
( (
cstrIter() ctorPtr
( (
fieldName, fieldName,
matrix, matrix,
@ -120,9 +120,9 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
} }
else if (matrix.asymmetric()) else if (matrix.asymmetric())
{ {
auto cstrIter = asymMatrixConstructorTablePtr_->cfind(name); auto* ctorPtr = asymMatrixConstructorTable(name);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -135,7 +135,7 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
return autoPtr<lduMatrix::smoother> return autoPtr<lduMatrix::smoother>
( (
cstrIter() ctorPtr
( (
fieldName, fieldName,
matrix, matrix,

View File

@ -70,9 +70,9 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
} }
else if (matrix.symmetric()) else if (matrix.symmetric())
{ {
auto cstrIter = symMatrixConstructorTablePtr_->cfind(name); auto* ctorPtr = symMatrixConstructorTable(name);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -85,7 +85,7 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
return autoPtr<lduMatrix::solver> return autoPtr<lduMatrix::solver>
( (
cstrIter() ctorPtr
( (
fieldName, fieldName,
matrix, matrix,
@ -98,9 +98,9 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
} }
else if (matrix.asymmetric()) else if (matrix.asymmetric())
{ {
auto cstrIter = asymMatrixConstructorTablePtr_->cfind(name); auto* ctorPtr = asymMatrixConstructorTable(name);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -113,7 +113,7 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
return autoPtr<lduMatrix::solver> return autoPtr<lduMatrix::solver>
( (
cstrIter() ctorPtr
( (
fieldName, fieldName,
matrix, matrix,

View File

@ -319,9 +319,9 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
lduMeshConstructorTablePtr_ lduMeshConstructorTablePtr_
); );
auto cstrIter = lduMeshConstructorTablePtr_->cfind(agglomeratorType); auto* ctorPtr = lduMeshConstructorTable(agglomeratorType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown GAMGAgglomeration type " << "Unknown GAMGAgglomeration type "
@ -333,7 +333,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
<< exit(FatalError); << exit(FatalError);
} }
return store(cstrIter()(mesh, controlDict).ptr()); return store(ctorPtr(mesh, controlDict).ptr());
} }
} }
@ -370,20 +370,15 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
lduMatrixConstructorTablePtr_ lduMatrixConstructorTablePtr_
); );
if auto* ctorPtr = lduMatrixConstructorTable(agglomeratorType);
(
!lduMatrixConstructorTablePtr_ if (!ctorPtr)
|| !lduMatrixConstructorTablePtr_->found(agglomeratorType)
)
{ {
return New(mesh, controlDict); return New(mesh, controlDict);
} }
else else
{ {
auto cstrIter = return store(ctorPtr(matrix, controlDict).ptr());
lduMatrixConstructorTablePtr_->cfind(agglomeratorType);
return store(cstrIter()(matrix, controlDict).ptr());
} }
} }
} }
@ -422,9 +417,9 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
geometryConstructorTablePtr_ geometryConstructorTablePtr_
); );
auto cstrIter = geometryConstructorTablePtr_->cfind(agglomeratorType); auto* ctorPtr = geometryConstructorTable(agglomeratorType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown GAMGAgglomeration type " << "Unknown GAMGAgglomeration type "
@ -436,7 +431,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
return store return store
( (
cstrIter() ctorPtr
( (
mesh, mesh,
cellVolumes, cellVolumes,

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -364,9 +365,9 @@ Foam::autoPtr<Foam::GAMGProcAgglomeration> Foam::GAMGProcAgglomeration::New
{ {
DebugInFunction << "Constructing GAMGProcAgglomeration" << endl; DebugInFunction << "Constructing GAMGProcAgglomeration" << endl;
auto cstrIter = GAMGAgglomerationConstructorTablePtr_->cfind(type); auto* ctorPtr = GAMGAgglomerationConstructorTable(type);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown GAMGProcAgglomeration type " << "Unknown GAMGProcAgglomeration type "
@ -376,7 +377,7 @@ Foam::autoPtr<Foam::GAMGProcAgglomeration> Foam::GAMGProcAgglomeration::New
<< exit(FatalError); << exit(FatalError);
} }
return autoPtr<GAMGProcAgglomeration>(cstrIter()(agglom, controlDict)); return autoPtr<GAMGProcAgglomeration>(ctorPtr(agglom, controlDict));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -38,9 +38,9 @@ Foam::autoPtr<Foam::GAMGInterfaceField> Foam::GAMGInterfaceField::New
{ {
const word coupleType(fineInterface.interfaceFieldType()); const word coupleType(fineInterface.interfaceFieldType());
auto cstrIter = lduInterfaceFieldConstructorTablePtr_->cfind(coupleType); auto* ctorPtr = lduInterfaceFieldConstructorTable(coupleType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInLookup FatalErrorInLookup
( (
@ -50,7 +50,7 @@ Foam::autoPtr<Foam::GAMGInterfaceField> Foam::GAMGInterfaceField::New
) << exit(FatalError); ) << exit(FatalError);
} }
return autoPtr<GAMGInterfaceField>(cstrIter()(GAMGCp, fineInterface)); return autoPtr<GAMGInterfaceField>(ctorPtr(GAMGCp, fineInterface));
} }
@ -63,9 +63,9 @@ Foam::autoPtr<Foam::GAMGInterfaceField> Foam::GAMGInterfaceField::New
{ {
const word coupleType(GAMGCp.type()); const word coupleType(GAMGCp.type());
auto cstrIter = lduInterfaceConstructorTablePtr_->cfind(coupleType); auto* ctorPtr = lduInterfaceConstructorTable(coupleType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInLookup FatalErrorInLookup
( (
@ -75,7 +75,7 @@ Foam::autoPtr<Foam::GAMGInterfaceField> Foam::GAMGInterfaceField::New
) << exit(FatalError); ) << exit(FatalError);
} }
return autoPtr<GAMGInterfaceField>(cstrIter()(GAMGCp, doTransform, rank)); return autoPtr<GAMGInterfaceField>(ctorPtr(GAMGCp, doTransform, rank));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -46,9 +46,9 @@ Foam::autoPtr<Foam::GAMGInterface> Foam::GAMGInterface::New
{ {
const word coupleType(fineInterface.type()); const word coupleType(fineInterface.type());
auto cstrIter = lduInterfaceConstructorTablePtr_->cfind(coupleType); auto* ctorPtr = lduInterfaceConstructorTable(coupleType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInLookup FatalErrorInLookup
( (
@ -60,7 +60,7 @@ Foam::autoPtr<Foam::GAMGInterface> Foam::GAMGInterface::New
return autoPtr<GAMGInterface> return autoPtr<GAMGInterface>
( (
cstrIter() ctorPtr
( (
index, index,
coarseInterfaces, coarseInterfaces,
@ -82,9 +82,9 @@ Foam::autoPtr<Foam::GAMGInterface> Foam::GAMGInterface::New
Istream& is Istream& is
) )
{ {
auto cstrIter = IstreamConstructorTablePtr_->cfind(coupleType); auto* ctorPtr = IstreamConstructorTable(coupleType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInLookup FatalErrorInLookup
( (
@ -94,7 +94,7 @@ Foam::autoPtr<Foam::GAMGInterface> Foam::GAMGInterface::New
) << exit(FatalError); ) << exit(FatalError);
} }
return autoPtr<GAMGInterface>(cstrIter()(index, coarseInterfaces, is)); return autoPtr<GAMGInterface>(ctorPtr(index, coarseInterfaces, is));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -38,9 +38,9 @@ Foam::autoPtr<Foam::facePointPatch> Foam::facePointPatch::New
{ {
DebugInFunction << "Constructing facePointPatch" << endl; DebugInFunction << "Constructing facePointPatch" << endl;
auto cstrIter = polyPatchConstructorTablePtr_->cfind(patch.type()); auto* ctorPtr = polyPatchConstructorTable(patch.type());
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInLookup FatalErrorInLookup
( (
@ -50,7 +50,7 @@ Foam::autoPtr<Foam::facePointPatch> Foam::facePointPatch::New
) << exit(FatalError); ) << exit(FatalError);
} }
return autoPtr<facePointPatch>(cstrIter()(patch, bm)); return autoPtr<facePointPatch>(ctorPtr(patch, bm));
} }

View File

@ -276,21 +276,27 @@ Foam::polyPatch::~polyPatch()
bool Foam::polyPatch::constraintType(const word& pt) bool Foam::polyPatch::constraintType(const word& pt)
{ {
return pointPatchField<scalar>::pointPatchConstructorTablePtr_->found(pt); return
(
pointPatchField<scalar>::pointPatchConstructorTablePtr_
&& pointPatchField<scalar>::pointPatchConstructorTablePtr_->found(pt)
);
} }
Foam::wordList Foam::polyPatch::constraintTypes() Foam::wordList Foam::polyPatch::constraintTypes()
{ {
wordList cTypes(dictionaryConstructorTablePtr_->size()); const auto& cnstrTable = *dictionaryConstructorTablePtr_;
wordList cTypes(cnstrTable.size());
label i = 0; label i = 0;
forAllConstIters(*dictionaryConstructorTablePtr_, cstrIter) forAllConstIters(cnstrTable, iter)
{ {
if (constraintType(cstrIter.key())) if (constraintType(iter.key()))
{ {
cTypes[i++] = cstrIter.key(); cTypes[i++] = iter.key();
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -43,9 +43,9 @@ Foam::autoPtr<Foam::polyPatch> Foam::polyPatch::New
{ {
DebugInFunction << "Constructing polyPatch" << endl; DebugInFunction << "Constructing polyPatch" << endl;
auto cstrIter = wordConstructorTablePtr_->cfind(patchType); auto* ctorPtr = wordConstructorTable(patchType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInLookup FatalErrorInLookup
( (
@ -57,7 +57,7 @@ Foam::autoPtr<Foam::polyPatch> Foam::polyPatch::New
return autoPtr<polyPatch> return autoPtr<polyPatch>
( (
cstrIter() ctorPtr
( (
name, name,
size, size,
@ -98,16 +98,16 @@ Foam::autoPtr<Foam::polyPatch> Foam::polyPatch::New
{ {
DebugInFunction << "Constructing polyPatch" << endl; DebugInFunction << "Constructing polyPatch" << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(patchType); auto* ctorPtr = dictionaryConstructorTable(patchType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
if (!disallowGenericPolyPatch) if (!disallowGenericPolyPatch)
{ {
cstrIter = dictionaryConstructorTablePtr_->cfind("genericPatch"); ctorPtr = dictionaryConstructorTable("genericPatch");
} }
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -119,7 +119,7 @@ Foam::autoPtr<Foam::polyPatch> Foam::polyPatch::New
} }
} }
return autoPtr<polyPatch>(cstrIter()(name, dict, index, bm, patchType)); return autoPtr<polyPatch>(ctorPtr(name, dict, index, bm, patchType));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -43,9 +43,9 @@ Foam::autoPtr<Foam::cellZone> Foam::cellZone::New
const word zoneType(dict.get<word>("type")); const word zoneType(dict.get<word>("type"));
auto cstrIter = dictionaryConstructorTablePtr_->cfind(zoneType); auto* ctorPtr = dictionaryConstructorTable(zoneType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -56,7 +56,7 @@ Foam::autoPtr<Foam::cellZone> Foam::cellZone::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<cellZone>(cstrIter()(name, dict, index, zm)); return autoPtr<cellZone>(ctorPtr(name, dict, index, zm));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -43,9 +43,9 @@ Foam::autoPtr<Foam::faceZone> Foam::faceZone::New
const word zoneType(dict.get<word>("type")); const word zoneType(dict.get<word>("type"));
auto cstrIter = dictionaryConstructorTablePtr_->cfind(zoneType); auto* ctorPtr = dictionaryConstructorTable(zoneType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -56,7 +56,7 @@ Foam::autoPtr<Foam::faceZone> Foam::faceZone::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<faceZone>(cstrIter()(name, dict, index, zm)); return autoPtr<faceZone>(ctorPtr(name, dict, index, zm));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -43,9 +43,9 @@ Foam::autoPtr<Foam::pointZone> Foam::pointZone::New
const word zoneType(dict.get<word>("type")); const word zoneType(dict.get<word>("type"));
auto cstrIter = dictionaryConstructorTablePtr_->cfind(zoneType); auto* ctorPtr = dictionaryConstructorTable(zoneType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -56,7 +56,7 @@ Foam::autoPtr<Foam::pointZone> Foam::pointZone::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<pointZone>(cstrIter()(name, dict, index, zm)); return autoPtr<pointZone>(ctorPtr(name, dict, index, zm));
} }

View File

@ -123,9 +123,9 @@ Foam::Function1<Type>::New
} }
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInFunction(dict) FatalIOErrorInFunction(dict)
<< "Unknown Function1 type " << "Unknown Function1 type "
@ -135,7 +135,7 @@ Foam::Function1<Type>::New
<< exit(FatalIOError); << exit(FatalIOError);
} }
return cstrIter()(entryName, *coeffs); return ctorPtr(entryName, *coeffs);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -161,9 +161,7 @@ static void expandLeadingTilde(std::string& s)
// Compat Warning // Compat Warning
const int version(1806); const int version(1806);
// Single warning (on master) with guard to avoid Pstream::master() if (error::master())
// when Pstream has not yet been initialized
if (UPstream::parRun() ? UPstream::master() : true)
{ {
std::cerr std::cerr
<< nl << nl

View File

@ -163,9 +163,9 @@ Foam::LESModel<BasicTurbulenceModel>::New
Info<< "Selecting LES turbulence model " << modelType << endl; Info<< "Selecting LES turbulence model " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -178,7 +178,7 @@ Foam::LESModel<BasicTurbulenceModel>::New
return autoPtr<LESModel> return autoPtr<LESModel>
( (
cstrIter()(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName) ctorPtr(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName)
); );
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -77,9 +77,9 @@ Foam::autoPtr<Foam::LESdelta> Foam::LESdelta::New
Info<< "Selecting LES " << lookupName << " type " << deltaType << endl; Info<< "Selecting LES " << lookupName << " type " << deltaType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(deltaType); auto* ctorPtr = dictionaryConstructorTable(deltaType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -90,7 +90,7 @@ Foam::autoPtr<Foam::LESdelta> Foam::LESdelta::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<LESdelta>(cstrIter()(name, turbulence, dict)); return autoPtr<LESdelta>(ctorPtr(name, turbulence, dict));
} }
@ -99,7 +99,7 @@ Foam::autoPtr<Foam::LESdelta> Foam::LESdelta::New
const word& name, const word& name,
const turbulenceModel& turbulence, const turbulenceModel& turbulence,
const dictionary& dict, const dictionary& dict,
const dictionaryConstructorTable& additionalConstructors, const dictionaryConstructorTableType& additionalConstructors,
const word& lookupName const word& lookupName
) )
{ {
@ -109,30 +109,37 @@ Foam::autoPtr<Foam::LESdelta> Foam::LESdelta::New
// First any additional ones // First any additional ones
{ {
auto cstrIter = additionalConstructors.cfind(deltaType); auto ctorIter = additionalConstructors.cfind(deltaType);
if (cstrIter.found()) if (ctorIter.found())
{ {
return autoPtr<LESdelta>(cstrIter()(name, turbulence, dict)); return autoPtr<LESdelta>(ctorIter.val()(name, turbulence, dict));
} }
} }
auto cstrIter = dictionaryConstructorTablePtr_->cfind(deltaType); auto* ctorPtr = dictionaryConstructorTable(deltaType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
dict, dict,
"LESdelta", "LESdelta",
deltaType, deltaType,
additionalConstructors *dictionaryConstructorTablePtr_
) );
<< " and " << dictionaryConstructorTablePtr_->sortedToc()
if (!additionalConstructors.empty())
{
FatalIOError
<< " and " << additionalConstructors.sortedToc() << nl;
}
FatalIOError
<< exit(FatalIOError); << exit(FatalIOError);
} }
return autoPtr<LESdelta>(cstrIter()(name, turbulence, dict)); return autoPtr<LESdelta>(ctorPtr(name, turbulence, dict));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -53,10 +53,9 @@ namespace Foam
class LESdelta class LESdelta
{ {
protected: protected:
// Protected data // Protected Data
const turbulenceModel& turbulenceModel_; const turbulenceModel& turbulenceModel_;
@ -121,7 +120,7 @@ public:
const word& name, const word& name,
const turbulenceModel& turbulence, const turbulenceModel& turbulence,
const dictionary& dict, const dictionary& dict,
const dictionaryConstructorTable& additionalConstructors, const dictionaryConstructorTableType& additionalConstructors,
const word& lookupName = "delta" const word& lookupName = "delta"
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -49,9 +49,9 @@ Foam::autoPtr<Foam::LESfilter> Foam::LESfilter::New
{ {
const word filterType(dict.get<word>(filterDictName)); const word filterType(dict.get<word>(filterDictName));
auto cstrIter = dictionaryConstructorTablePtr_->cfind(filterType); auto* ctorPtr = dictionaryConstructorTable(filterType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -62,7 +62,7 @@ Foam::autoPtr<Foam::LESfilter> Foam::LESfilter::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<LESfilter>(cstrIter()(mesh, dict)); return autoPtr<LESfilter>(ctorPtr(mesh, dict));
} }

View File

@ -145,9 +145,9 @@ Foam::RASModel<BasicTurbulenceModel>::New
Info<< "Selecting RAS turbulence model " << modelType << endl; Info<< "Selecting RAS turbulence model " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -160,7 +160,7 @@ Foam::RASModel<BasicTurbulenceModel>::New
return autoPtr<RASModel> return autoPtr<RASModel>
( (
cstrIter()(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName) ctorPtr(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName)
); );
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -105,9 +105,9 @@ Foam::TurbulenceModel<Alpha, Rho, BasicTurbulenceModel, TransportModel>::New
Info<< "Selecting turbulence model type " << modelType << endl; Info<< "Selecting turbulence model type " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -120,7 +120,7 @@ Foam::TurbulenceModel<Alpha, Rho, BasicTurbulenceModel, TransportModel>::New
return autoPtr<TurbulenceModel> return autoPtr<TurbulenceModel>
( (
cstrIter()(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName) ctorPtr(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName)
); );
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenFOAM Foundation Copyright (C) 2018-2020 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -40,9 +40,9 @@ Foam::laminarModels::generalizedNewtonianViscosityModel::New
Info<< "Selecting generalized Newtonian model " << modelType << endl; Info<< "Selecting generalized Newtonian model " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->find(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -53,7 +53,7 @@ Foam::laminarModels::generalizedNewtonianViscosityModel::New
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<generalizedNewtonianViscosityModel>(cstrIter()(dict)); return autoPtr<generalizedNewtonianViscosityModel>(ctorPtr(dict));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -120,9 +120,9 @@ Foam::laminarModel<BasicTurbulenceModel>::New
Info<< "Selecting laminar stress model " << modelType << endl; Info<< "Selecting laminar stress model " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -135,7 +135,7 @@ Foam::laminarModel<BasicTurbulenceModel>::New
return autoPtr<laminarModel> return autoPtr<laminarModel>
( (
cstrIter() ctorPtr
( (
alpha, alpha,
rho, rho,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -45,9 +45,9 @@ Foam::autoPtr<Foam::reactionRateFlameArea> Foam::reactionRateFlameArea::New
Info<< "Selecting reaction rate flame area correlation " Info<< "Selecting reaction rate flame area correlation "
<< modelType << endl; << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); auto* ctorPtr = dictionaryConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -61,7 +61,7 @@ Foam::autoPtr<Foam::reactionRateFlameArea> Foam::reactionRateFlameArea::New
const word className = modelType.substr(0, modelType.find('<')); const word className = modelType.substr(0, modelType.find('<'));
return autoPtr<reactionRateFlameArea> return autoPtr<reactionRateFlameArea>
(cstrIter()(className, dict, mesh, combModel)); (ctorPtr(className, dict, mesh, combModel));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -73,6 +73,7 @@ Foam::autoPtr<CombustionModel> Foam::combustionModel::New
<< "combustion model " << combModelName << "." << endl; << "combustion model " << combModelName << "." << endl;
} }
const word compCombModelName const word compCombModelName
( (
combModelName + '<' + CombustionModel::reactionThermo::typeName + '>' combModelName + '<' + CombustionModel::reactionThermo::typeName + '>'
@ -87,20 +88,27 @@ Foam::autoPtr<CombustionModel> Foam::combustionModel::New
const auto& cnstrTable = *(CombustionModel::dictionaryConstructorTablePtr_); const auto& cnstrTable = *(CombustionModel::dictionaryConstructorTablePtr_);
auto compCstrIter = cnstrTable.cfind(compCombModelName); auto ctorIter = cnstrTable.cfind(thermoCombModelName);
auto thermoCstrIter = cnstrTable.cfind(thermoCombModelName); if (!ctorIter.found())
if (!compCstrIter.found() && !thermoCstrIter.found())
{ {
wordList thisCmpts; ctorIter = cnstrTable.cfind(compCombModelName);
thisCmpts.append(word::null); }
thisCmpts.append(CombustionModel::reactionThermo::typeName);
thisCmpts.append(basicThermo::splitThermoName(thermo.thermoName(), 5));
wordList validNames; if (!ctorIter.found())
{
const wordList names(cnstrTable.sortedToc());
List<wordList> validCmpts2; /// DynamicList<word> thisCmpts(6);
/// thisCmpts.append(CombustionModel::reactionThermo::typeName);
/// thisCmpts.append(basicThermo::splitThermoName
/// (
/// basicThermo::splitThermoName(thermo.thermoName(), 5)
/// );
///
/// DynamicList<word> validNames;
DynamicList<wordList> validCmpts2;
validCmpts2.append validCmpts2.append
( (
// Header // Header
@ -112,7 +120,7 @@ Foam::autoPtr<CombustionModel> Foam::combustionModel::New
}) })
); );
List<wordList> validCmpts7; DynamicList<wordList> validCmpts7;
validCmpts7.append validCmpts7.append
( (
// Header // Header
@ -129,61 +137,56 @@ Foam::autoPtr<CombustionModel> Foam::combustionModel::New
}) })
); );
for (const word& validName : cnstrTable.sortedToc()) for (const word& validName : names)
{ {
wordList cmpts(basicThermo::splitThermoName(validName, 2)); wordList cmpts(basicThermo::splitThermoName(validName, 0));
if (cmpts.size() == 2) if (cmpts.size() == 2)
{ {
validCmpts2.append(cmpts); validCmpts2.append(std::move(cmpts));
} }
else else if (cmpts.size() == 7)
{ {
cmpts = basicThermo::splitThermoName(validName, 7); /// if (thisCmpts == SubList<word>(cmpts, 6, 1))
if (cmpts.size() == 7) /// {
{ /// validNames.append(cmpts[0]);
validCmpts7.append(cmpts); /// }
validCmpts7.append(std::move(cmpts));
} }
} }
bool isValid = true;
for (label i = 1; i < cmpts.size() && isValid; ++i)
{
isValid = isValid && cmpts[i] == thisCmpts[i];
}
if (isValid)
{
validNames.append(cmpts[0]);
}
}
FatalErrorInLookup FatalErrorInLookup
( (
combustionModel::typeName, combustionModel::typeName,
combModelName, combModelName,
cnstrTable cnstrTable
) );
if (validCmpts2.size() > 1)
{
FatalError
<< "All " << validCmpts2[0][0] << '/' << validCmpts2[0][1] << "All " << validCmpts2[0][0] << '/' << validCmpts2[0][1]
<< " combinations are:" << nl << nl; << " combinations are:" << nl << nl;
printTable(validCmpts2, FatalErrorInFunction) printTable(validCmpts2, FatalError) << nl;
<< nl; }
FatalErrorInFunction if (validCmpts7.size() > 1)
{
FatalError
<< "All " << validCmpts7[0][0] << '/' << validCmpts7[0][1] << "All " << validCmpts7[0][0] << '/' << validCmpts7[0][1]
<< "/thermoPhysics combinations are:" << nl << nl; << "/thermoPhysics combinations are:" << nl << nl;
printTable(validCmpts7, FatalErrorInFunction) printTable(validCmpts7, FatalError) << nl;
}
FatalError
<< exit(FatalError); << exit(FatalError);
} }
return autoPtr<CombustionModel> return autoPtr<CombustionModel>
( (
thermoCstrIter.found() ctorIter.val()(combModelName, thermo, turb, combustionProperties)
? thermoCstrIter()(combModelName, thermo, turb, combustionProperties)
: compCstrIter()(combModelName, thermo, turb, combustionProperties)
); );
} }

View File

@ -72,9 +72,8 @@ Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io)
<< exit(FatalError); << exit(FatalError);
} }
auto doInitCstrIter = doInitConstructorTablePtr_->cfind(modelType); auto* doInitCtor = doInitConstructorTable(modelType);
if (doInitCtor)
if (doInitCstrIter.found())
{ {
DebugInfo DebugInfo
<< "Constructing dynamicFvMesh with explicit initialisation" << "Constructing dynamicFvMesh with explicit initialisation"
@ -82,7 +81,7 @@ Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io)
// Two-step constructor // Two-step constructor
// 1. Construct mesh, do not initialise // 1. Construct mesh, do not initialise
autoPtr<dynamicFvMesh> meshPtr(doInitCstrIter()(io, false)); autoPtr<dynamicFvMesh> meshPtr(doInitCtor(io, false));
// 2. Initialise parents and itself // 2. Initialise parents and itself
meshPtr().init(true); meshPtr().init(true);
@ -90,9 +89,9 @@ Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io)
return meshPtr; return meshPtr;
} }
auto cstrIter = IOobjectConstructorTablePtr_->cfind(modelType); auto* ctorPtr = IOobjectConstructorTable(modelType);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalIOErrorInLookup FatalIOErrorInLookup
( (
@ -103,7 +102,7 @@ Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io)
) << exit(FatalIOError); ) << exit(FatalIOError);
} }
return autoPtr<dynamicFvMesh>(cstrIter()(io)); return autoPtr<dynamicFvMesh>(ctorPtr(io));
} }
DebugInfo DebugInfo

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -64,12 +64,12 @@ Foam::simplifiedMeshes::simplifiedDynamicFvMeshBase::New
const word modelType(dict.get<word>("dynamicFvMesh")); const word modelType(dict.get<word>("dynamicFvMesh"));
auto cstrIter = timeConstructorTablePtr_->cfind(modelType); auto* ctorPtr = timeConstructorTable(modelType);
if (cstrIter.found()) if (ctorPtr)
{ {
Info<< "Selecting simplified mesh model " << modelType << endl; Info<< "Selecting simplified mesh model " << modelType << endl;
return autoPtr<dynamicFvMesh>(cstrIter()(io.time(), io.name())); return autoPtr<dynamicFvMesh>(ctorPtr(io.time(), io.name()));
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -48,9 +48,9 @@ Foam::autoPtr<Foam::cellLooper> Foam::cellLooper::New
const polyMesh& mesh const polyMesh& mesh
) )
{ {
auto cstrIter = wordConstructorTablePtr_->cfind(type); auto* ctorPtr = wordConstructorTable(type);
if (!cstrIter.found()) if (!ctorPtr)
{ {
FatalErrorInLookup FatalErrorInLookup
( (
@ -60,7 +60,7 @@ Foam::autoPtr<Foam::cellLooper> Foam::cellLooper::New
) << exit(FatalError); ) << exit(FatalError);
} }
return autoPtr<cellLooper>(cstrIter()(mesh)); return autoPtr<cellLooper>(ctorPtr(mesh));
} }

Some files were not shown because too many files have changed in this diff Show More