From 3b7451223113d7afa8c4c1b21ff36bcb28c5532a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 18 Oct 2018 12:57:32 +0200 Subject: [PATCH] ENH: cleanup of Enum class - more dictionary-like methods, enforce keyType::LITERAL for all lookups to avoid any spurious keyword matching. - new readEntry, readIfPresent methods - The get() method replaces the now deprecate lookup() method. - Deprecate lookupOrFailsafe() Failsafe behaviour is now an optional parameter for lookupOrDefault, which makes it easier to tailor behaviour at runtime. - output of the names is now always flatted without line-breaks. Thus, os << flatOutput(someEnumNames.names()) << nl; os << someEnumNames << nl; both generate the same output. - Constructor now uses C-string (const char*) directly instead of Foam::word in its initializer_list. - Remove special enum + initializer_list constructor form since it can create unbounded lookup indices. - Removd old hasEnum, hasName forms that were provided during initial transition from NamedEnum. - Added static_assert on Enum contents to restrict to enum or integral values. Should not likely be using this class to enumerate other things since it internally uses an 'int' for its values. Changed volumeType accordingly to enumerate on its type (enum), not the class itself. --- .../laserDTRM/laserDTRM.C | 4 +- ...allBoilingWallFunctionFvPatchScalarField.C | 6 +- applications/test/Enum/Make/files | 3 + .../test/{NamedEnum => Enum}/Make/options | 0 applications/test/Enum/Test-Enum.C | 166 +++++++++++ applications/test/NamedEnum/Make/files | 3 - applications/test/NamedEnum/Test-NamedEnum.C | 161 ----------- .../extrude/extrudeMesh/extrudeMesh.C | 6 +- .../extrudeToRegionMesh/extrudeToRegionMesh.C | 2 +- .../conformalVoronoiMesh.C | 4 +- .../indexedCell/indexedCellEnum.C | 4 +- .../indexedVertex/indexedVertexEnum.C | 4 +- .../mesh/manipulation/topoSet/topoSet.C | 2 +- .../miscellaneous/postChannel/channelIndex.C | 10 +- .../createZeroDirectory/solverTemplate.C | 10 +- .../setAlphaField/setAlphaField.C | 6 +- .../tabulatedWallFunction/general/general.C | 6 +- src/OSspecific/POSIX/fileMonitor.C | 4 +- .../algorithms/indexedOctree/volumeType.C | 14 +- .../algorithms/indexedOctree/volumeType.H | 2 +- src/OpenFOAM/db/IOobject/IOobject.C | 6 +- .../db/IOstreams/IOstreams/IOstreamOption.C | 6 +- src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C | 12 +- src/OpenFOAM/db/Time/Time.C | 8 +- src/OpenFOAM/db/Time/TimeIO.C | 18 +- .../functionEntries/inputMode/inputMode.C | 6 +- .../functionObjects/timeControl/timeControl.C | 14 +- .../interpolation2DTable.C | 5 +- .../interpolationTable/interpolationTable.C | 5 +- .../basic/coupled/coupledPolyPatch.C | 4 +- .../primitiveShapes/triangle/intersection.C | 8 +- src/OpenFOAM/orientedType/orientedType.C | 18 +- src/OpenFOAM/primitives/bools/Switch/Switch.C | 2 +- src/OpenFOAM/primitives/bools/Switch/Switch.H | 4 +- src/OpenFOAM/primitives/enums/Enum.C | 272 +++++++----------- src/OpenFOAM/primitives/enums/Enum.H | 191 ++++++------ src/OpenFOAM/primitives/enums/EnumI.H | 79 +++-- .../functions/Function1/Table/TableBase.C | 5 +- ...allHeatFluxTemperatureFvPatchScalarField.C | 6 +- .../temperatureCoupledBase.C | 6 +- src/combustionModels/EDC/EDCs.C | 4 +- .../meshCut/directions/directions.C | 4 +- .../polyTopoChange/tetDecomposer.C | 4 +- .../slidingInterface/slidingInterface.C | 8 +- src/fileFormats/coordSet/coordSet.C | 6 +- src/fileFormats/fire/FIRECore.C | 6 +- src/fileFormats/nas/NASCore.C | 4 +- src/fileFormats/starcd/STARCDCore.C | 12 +- src/fileFormats/vtk/core/foamVtkCore.C | 12 +- src/fileFormats/vtk/output/foamVtkOutput.C | 8 +- .../vtk/read/vtkUnstructuredReader.C | 18 +- .../fanPressureFvPatchScalarField.C | 6 +- .../waveSurfacePressureFvPatchScalarField.C | 4 +- .../functionObjects/volRegion/volRegion.C | 4 +- .../fieldAverageItem/fieldAverageItem.C | 8 +- .../fieldAverageItem/fieldAverageItemIO.C | 5 +- .../field/fieldMinMax/fieldMinMax.C | 4 +- .../fieldValueDelta/fieldValueDelta.C | 6 +- .../surfaceFieldValue/surfaceFieldValue.C | 26 +- .../fieldValues/volFieldValue/volFieldValue.C | 8 +- .../field/fluxSummary/fluxSummary.C | 6 +- src/functionObjects/field/setFlow/setFlow.C | 9 +- .../field/turbulenceFields/turbulenceFields.C | 12 +- .../fieldVisualisationBase.C | 15 +- .../runTimePostProcessing/geometryBase.C | 14 +- .../graphics/runTimePostProcessing/pathline.C | 6 +- .../runTimePostProcessing/pointData.C | 6 +- .../graphics/runTimePostProcessing/surface.C | 6 +- .../utilities/ensightWrite/ensightWrite.C | 5 +- .../equationInitialResidualCondition.C | 6 +- .../minMaxCondition/minMaxCondition.C | 6 +- .../utilities/writeObjects/writeObjects.C | 8 +- ...surfaceDisplacementPointPatchVectorField.C | 6 +- ...aceSlipDisplacementPointPatchVectorField.C | 6 +- src/fvOptions/cellSetOption/cellSetOption.C | 9 +- .../fixedTemperatureConstraint.C | 6 +- ...irectionalPressureGradientExplicitSource.C | 6 +- .../derived/rotorDiskSource/rotorDiskSource.C | 12 +- .../solidificationMeltingSource.C | 8 +- .../tabulatedNTUHeatTransfer.C | 6 +- .../phaseProperties/phaseProperties.C | 4 +- .../ConeNozzleInjection/ConeNozzleInjection.C | 16 +- src/lumpedPointMotion/lumpedPointMovement.C | 26 +- src/lumpedPointMotion/lumpedPointState.C | 6 +- .../meshRefinement/meshRefinement.C | 12 +- .../refinementSurfaces/surfaceZonesInfo.C | 8 +- .../shellSurfaces/shellSurfaces.C | 6 +- .../AMIInterpolation/AMIInterpolation.C | 4 +- .../faceAreaIntersect/faceAreaIntersect.C | 6 +- .../extendedEdgeMesh/extendedEdgeMesh.C | 13 +- .../mappedPolyPatch/mappedPatchBase.C | 14 +- .../sets/cellSources/faceToCell/faceToCell.C | 6 +- .../faceZoneToCell/faceZoneToCell.C | 6 +- .../cellSources/pointToCell/pointToCell.C | 6 +- .../sets/faceSources/cellToFace/cellToFace.C | 6 +- .../faceSources/pointToFace/pointToFace.C | 6 +- .../pointSources/cellToPoint/cellToPoint.C | 6 +- .../pointSources/faceToPoint/faceToPoint.C | 6 +- .../sets/topoSetSource/topoSetSource.C | 4 +- .../booleanSurface/booleanSurface.C | 4 +- .../surfaceIntersection/surfaceIntersection.C | 4 +- .../triSurfaceLoader/triSurfaceLoader.C | 6 +- .../cellCellStencil/cellCellStencil.C | 4 +- .../decompose/kahipDecomp/kahipDecomp.C | 8 +- .../distributedTriSurfaceMesh.C | 6 +- .../energyRegionCoupledFvPatchScalarField.C | 4 +- src/sampling/meshToMesh/meshToMesh.C | 4 +- .../sampledPatchInternalField.C | 10 +- .../sampledTriSurfaceMesh.C | 6 +- .../writers/ensight/ensightSurfaceWriter.C | 5 +- .../writers/nastran/nastranSurfaceWriter.C | 4 +- .../surface/triSurfaceMesh/discreteSurface.C | 6 +- .../sixDoFRigidBodyState.C | 6 +- .../boundaryRadiationPropertiesPatch.C | 8 +- .../solarCalculator/solarCalculator.C | 16 +- ...emperatureCoupledMixedFvPatchScalarField.C | 7 +- .../alphaContactAngleFvPatchScalarField.C | 6 +- 117 files changed, 825 insertions(+), 857 deletions(-) create mode 100644 applications/test/Enum/Make/files rename applications/test/{NamedEnum => Enum}/Make/options (100%) create mode 100644 applications/test/Enum/Test-Enum.C delete mode 100644 applications/test/NamedEnum/Make/files delete mode 100644 applications/test/NamedEnum/Test-NamedEnum.C diff --git a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C index f941743c47..d57eeefd48 100644 --- a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C +++ b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C @@ -322,7 +322,7 @@ void Foam::radiation::laserDTRM::initialise() Foam::radiation::laserDTRM::laserDTRM(const volScalarField& T) : radiationModel(typeName, T), - mode_(powerDistNames_.lookup("mode", *this)), + mode_(powerDistNames_.get("mode", *this)), DTRMCloud_(mesh_, "DTRMCloud", IDLList()), nParticles_(0), ndTheta_(get