From d88272f031d9c90485da029455ce6d65bfcdb9fa Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 22 Feb 2023 18:25:33 +0100 Subject: [PATCH] ENH: relocate zero_one to pTraits, allows reuse for scalar clamping ENH: add pTraits and IO for std::int8_t STYLE: cull some implicitly available includes - pTraits.H is included by label/scalar etc - zero.H is included by UList STYLE: cull redundant forward declarations for Istream/Ostream --- applications/test/List/Test-List.C | 2 +- applications/test/minMax2/Test-minMax2.C | 3 +- applications/test/sizeof/Test-sizeof.C | 6 +- .../mesh/advanced/selectCells/edgeStats.H | 7 +- .../pdrFields/obstacles/PDRobstacleTypes.C | 4 +- .../setAlphaField/setAlphaField.C | 2 +- src/OSspecific/MSwindows/cpuInfo/cpuInfo.H | 2 +- src/OSspecific/POSIX/cpuInfo/cpuInfo.H | 2 +- src/OpenFOAM/Make/files | 7 +- .../dynamicIndexedOctree.H | 1 - .../algorithms/indexedOctree/indexedOctree.H | 1 - .../LinkedLists/accessTypes/ILList/ILList.H | 3 - .../LinkedLists/accessTypes/LList/LList.H | 4 - .../LinkedLists/accessTypes/UILList/UILList.H | 2 - src/OpenFOAM/containers/Lists/List/UList.H | 3 - src/OpenFOAM/containers/Lists/List/UListI.H | 1 - .../containers/Lists/policy/ListPolicy.H | 21 ++- .../IOobjects/CompactIOList/CompactIOList.H | 2 - .../db/IOstreams/IOstreams/InfoProxy.H | 12 +- .../db/IOstreams/memory/memoryStreamBuffer.H | 7 +- .../functionEntries/codeStream/codeStream.H | 1 + .../dimensionedType/dimensionedType.C | 1 - src/OpenFOAM/global/debug/debug.H | 2 +- src/OpenFOAM/global/debug/simpleRegIOobject.H | 2 +- src/OpenFOAM/global/profiling/profiling.H | 5 +- src/OpenFOAM/matrices/Matrix/MatrixTools.H | 7 +- src/OpenFOAM/primitives/Scalar/Scalar.H | 7 + .../Scalar/doubleScalar/doubleScalar.H | 5 +- .../Scalar/floatScalar/floatScalar.H | 5 +- .../primitives/VectorSpace/products.H | 4 +- src/OpenFOAM/primitives/bools/bool/bool.H | 35 ++-- src/OpenFOAM/primitives/chars/char/char.H | 29 +--- src/OpenFOAM/primitives/chars/wchar/wchar.H | 4 +- src/OpenFOAM/primitives/complex/complex.H | 15 +- src/OpenFOAM/primitives/direction/direction.H | 10 +- .../primitives/direction/directionIO.C | 4 +- .../functions/Function1/ramp/ramp.H | 2 +- .../primitives/hashes/SHA1/SHA1Digest.H | 2 +- src/OpenFOAM/primitives/ints/int/int.H | 1 + src/OpenFOAM/primitives/ints/int16/int16.H | 9 +- src/OpenFOAM/primitives/ints/int32/int32.H | 30 ++-- src/OpenFOAM/primitives/ints/int64/int64.H | 30 ++-- src/OpenFOAM/primitives/ints/int8/int8.C | 105 ++++++++++++ src/OpenFOAM/primitives/ints/int8/int8.H | 154 ++++++++++++++++++ src/OpenFOAM/primitives/ints/uint16/uint16.H | 9 +- src/OpenFOAM/primitives/ints/uint32/uint32.H | 19 +-- src/OpenFOAM/primitives/ints/uint64/uint64.H | 18 +- src/OpenFOAM/primitives/ints/uint8/uint8.C | 14 ++ src/OpenFOAM/primitives/ints/uint8/uint8.H | 9 +- src/OpenFOAM/primitives/ints/uint8/uint8IO.C | 44 ----- .../primitives/random/Random/Random.H | 4 +- .../ranges/labelRange/labelRanges.H | 2 - .../ranges/scalarRange/scalarRange.H | 1 - .../primitives/ranges/sliceRange/sliceRange.H | 6 +- .../spatialTransform/spatialTransform.H | 6 +- src/OpenFOAM/primitives/traits/contiguous.H | 18 +- src/OpenFOAM/primitives/traits/one.H | 31 +--- src/OpenFOAM/primitives/traits/pTraits.H | 9 + src/OpenFOAM/primitives/traits/zero.H | 21 +-- src/finiteArea/faMatrices/faMatrix/faMatrix.H | 1 - .../edgeInterpolation/schemes/Gamma/Gamma.H | 2 +- .../derived/turbulentDFSEMInlet/eddy/eddy.H | 4 +- .../finiteVolume/fvm/fvmLaplacian.H | 1 - .../fvMatrices/fvMatrix/fvMatrix.H | 1 - .../fvMatrices/solvers/MULES/MULES.H | 1 - .../limitedSchemes/Gamma/Gamma.H | 2 +- .../limitedSchemes/Minmod/Minmod.H | 2 +- .../limitedSchemes/Phi/Phi.H | 2 +- .../filteredLinear2/filteredLinear2.H | 2 +- .../filteredLinear2/filteredLinear2V.H | 2 +- .../filteredLinear3/filteredLinear3.H | 2 +- .../filteredLinear3/filteredLinear3V.H | 2 +- .../limitedLinear/limitedLinear.H | 2 +- .../schemes/CoBlended/CoBlended.H | 2 +- .../eulerianParticle/eulerianParticle.H | 7 +- .../fieldAverageItem/fieldAverageItem.H | 6 +- .../surfaceFieldValue/surfaceFieldValue.C | 4 +- .../stabilityBlendingFactor.H | 2 +- .../solidificationMeltingSource.C | 2 +- .../distributionModels/binned/binned.H | 7 +- .../distributionModels/general/general.H | 8 +- .../DistortedSphereDragForce.C | 2 +- .../Templates/SprayParcel/SprayParcel.C | 2 +- .../movement/lumpedPointMovement.C | 2 +- .../state/lumpedPointState.H | 4 - .../gradingDescriptor/gradingDescriptor.H | 2 - .../gradingDescriptor/gradingDescriptors.H | 1 - .../PointIntegrateData/PointIntegrateData.H | 4 +- .../PatchEdgeFaceWave/patchEdgeFaceInfo.H | 3 +- .../algorithms/PointEdgeWave/PointData.H | 2 - .../algorithms/PointEdgeWave/pointEdgePoint.H | 3 +- .../edgeMesh/edgeMeshTools/edgeMeshTools.H | 6 +- .../MassTransferPhaseSystem.C | 4 +- .../rigidBodyInertia/rigidBodyInertia.H | 7 +- .../rigidBodyModelState/rigidBodyModelState.H | 7 +- .../surface/isoSurface/isoSurfaceParams.H | 5 +- ...gidBodyDisplacementPointPatchVectorField.C | 2 +- .../sixDoFRigidBodyMotionState.H | 2 - src/surfMesh/MeshedSurface/MeshedSurface.H | 2 - .../UnsortedMeshedSurface.H | 2 - .../waveMakerPointPatchVectorField.C | 2 +- .../irregularWaveModel/irregularWaveModel.C | 2 +- 102 files changed, 475 insertions(+), 427 deletions(-) create mode 100644 src/OpenFOAM/primitives/ints/int8/int8.C create mode 100644 src/OpenFOAM/primitives/ints/int8/int8.H delete mode 100644 src/OpenFOAM/primitives/ints/uint8/uint8IO.C diff --git a/applications/test/List/Test-List.C b/applications/test/List/Test-List.C index e676a859a4..03e77dcfef 100644 --- a/applications/test/List/Test-List.C +++ b/applications/test/List/Test-List.C @@ -81,7 +81,7 @@ namespace ListPolicy { // Override on a per-type basis -template<> struct short_length : std::integral_constant {}; +template<> struct short_length : std::integral_constant {}; } // End namespace ListPolicy } // End namespace Detail diff --git a/applications/test/minMax2/Test-minMax2.C b/applications/test/minMax2/Test-minMax2.C index 136681d75c..ec02d21d3d 100644 --- a/applications/test/minMax2/Test-minMax2.C +++ b/applications/test/minMax2/Test-minMax2.C @@ -146,7 +146,7 @@ int main(int argc, char *argv[]) Random rnd(4567); for (scalar& val : someField) { - val = rnd.position(-0.2, 1.2); + val = rnd.position(scalar(-0.2), scalar(1.2)); } Info<< nl @@ -171,6 +171,7 @@ int main(int argc, char *argv[]) // nope << " : " << clamp(val, zero_one{}) // nope << " : " << clamp(val, scalarMinMax(zero_one{})) << " : " << clamp(val, 0, 1) + << " : " << clamp(val, zero_one{}) << nl; } diff --git a/applications/test/sizeof/Test-sizeof.C b/applications/test/sizeof/Test-sizeof.C index a5bd8ce9a7..13f0aac07a 100644 --- a/applications/test/sizeof/Test-sizeof.C +++ b/applications/test/sizeof/Test-sizeof.C @@ -33,7 +33,7 @@ Description #include "Switch.H" #include "string.H" #include "dictionary.H" -#include "nil.H" +#include "zero.H" #include "IOstreams.H" #include "PstreamBuffers.H" #include "argList.H" @@ -82,8 +82,8 @@ int main(int argc, char *argv[]) } { - nil x; - cout<<"nil:" << sizeof(x) << nl; + zero x; + cout<<"zero:" << sizeof(x) << nl; } #if 0 { diff --git a/applications/utilities/mesh/advanced/selectCells/edgeStats.H b/applications/utilities/mesh/advanced/selectCells/edgeStats.H index 79e70feba3..d197fdcb30 100644 --- a/applications/utilities/mesh/advanced/selectCells/edgeStats.H +++ b/applications/utilities/mesh/advanced/selectCells/edgeStats.H @@ -34,8 +34,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef edgeStats_H -#define edgeStats_H +#ifndef Foam_edgeStats_H +#define Foam_edgeStats_H #include "direction.H" #include "scalar.H" @@ -45,9 +45,8 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward Declarations class polyMesh; -class Ostream; class twoDPointCorrector; /*---------------------------------------------------------------------------*\ diff --git a/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacleTypes.C b/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacleTypes.C index 31c559d86f..04e798cf0c 100644 --- a/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacleTypes.C +++ b/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacleTypes.C @@ -62,7 +62,7 @@ namespace Foam // Volume porosity -> blockage inline scalar getPorosity(const dictionary& dict) { - return 1 - clamp(dict.getOrDefault("porosity", 0), 0, 1); + return 1 - clamp(dict.getOrDefault("porosity", 0), zero_one{}); } // Direction porosities -> blockage @@ -74,7 +74,7 @@ inline vector getPorosities(const dictionary& dict) { for (scalar& val : blockage) { - val = 1 - clamp(val, 0, 1); + val = 1 - clamp(val, zero_one{}); } } diff --git a/applications/utilities/preProcessing/setAlphaField/setAlphaField.C b/applications/utilities/preProcessing/setAlphaField/setAlphaField.C index 1db1a547f4..78f9b77e55 100644 --- a/applications/utilities/preProcessing/setAlphaField/setAlphaField.C +++ b/applications/utilities/preProcessing/setAlphaField/setAlphaField.C @@ -108,7 +108,7 @@ void setAlpha { cutCell.calcSubCell(cellI, 0.0); - alpha1[cellI] = clamp(cutCell.VolumeOfFluid(), 0, 1); + alpha1[cellI] = clamp(cutCell.VolumeOfFluid(), zero_one{}); if (writeOBJ && (mag(cutCell.faceArea()) >= 1e-14)) { diff --git a/src/OSspecific/MSwindows/cpuInfo/cpuInfo.H b/src/OSspecific/MSwindows/cpuInfo/cpuInfo.H index 5b175074cb..7da2ac5bc6 100644 --- a/src/OSspecific/MSwindows/cpuInfo/cpuInfo.H +++ b/src/OSspecific/MSwindows/cpuInfo/cpuInfo.H @@ -50,7 +50,7 @@ SourceFiles namespace Foam { -// Forward declarations +// Forward Declarations class Ostream; /*---------------------------------------------------------------------------*\ diff --git a/src/OSspecific/POSIX/cpuInfo/cpuInfo.H b/src/OSspecific/POSIX/cpuInfo/cpuInfo.H index f9d5c5646b..37cac03d92 100644 --- a/src/OSspecific/POSIX/cpuInfo/cpuInfo.H +++ b/src/OSspecific/POSIX/cpuInfo/cpuInfo.H @@ -50,7 +50,7 @@ SourceFiles namespace Foam { -// Forward declarations +// Forward Declarations class Ostream; /*---------------------------------------------------------------------------*\ diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index b0404996bc..7753533552 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -42,22 +42,21 @@ $(chars)/lists/charUList.C primitives/direction/directionIO.C ints = primitives/ints +$(ints)/uint/uintIO.C $(ints)/uint8/uint8.C -$(ints)/uint8/uint8IO.C $(ints)/uint16/uint16.C $(ints)/uint32/uint32.C $(ints)/uint32/uint32IO.C $(ints)/uint64/uint64.C $(ints)/uint64/uint64IO.C -$(ints)/uint/uintIO.C +$(ints)/uLabel/uLabel.C +$(ints)/int/intIO.C $(ints)/int16/int16.C $(ints)/int32/int32.C $(ints)/int32/int32IO.C $(ints)/int64/int64.C $(ints)/int64/int64IO.C -$(ints)/int/intIO.C $(ints)/label/label.C -$(ints)/uLabel/uLabel.C $(ints)/lists/labelList.C $(ints)/lists/labelIOList.C $(ints)/lists/labelListIOList.C diff --git a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.H b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.H index 6a93fc4ba6..d1b9aaf3ca 100644 --- a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.H +++ b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.H @@ -48,7 +48,6 @@ namespace Foam { // Forward Declarations -class Istream; template class dynamicIndexedOctree; template Ostream& operator<<(Ostream&, const dynamicIndexedOctree&); diff --git a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.H b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.H index 3b9878365c..c9c7887e92 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.H +++ b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.H @@ -53,7 +53,6 @@ namespace Foam { // Forward Declarations -class Istream; template class indexedOctree; template Ostream& operator<<(Ostream&, const indexedOctree&); diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H index 038cfb7383..984c3c5400 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H @@ -47,9 +47,6 @@ namespace Foam { // Forward Declarations - -class Istream; -class Ostream; template class ILList; template Istream& operator>> diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H index c99dc344cd..9e7e39311c 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H @@ -48,10 +48,6 @@ namespace Foam { // Forward Declarations - -class Istream; -class Ostream; - template class LList; template diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H index 7c3448af24..c97c523968 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H @@ -49,8 +49,6 @@ namespace Foam { // Forward Declarations -class Ostream; - template class UILList; template diff --git a/src/OpenFOAM/containers/Lists/List/UList.H b/src/OpenFOAM/containers/Lists/List/UList.H index 2c6339e1c9..01d5d1b562 100644 --- a/src/OpenFOAM/containers/Lists/List/UList.H +++ b/src/OpenFOAM/containers/Lists/List/UList.H @@ -57,7 +57,6 @@ SourceFiles #include "ListPolicy.H" #include -#include #include // i.e, std::vector // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -66,8 +65,6 @@ namespace Foam { // Forward Declarations -class Istream; -class Ostream; class labelRange; template class List; diff --git a/src/OpenFOAM/containers/Lists/List/UListI.H b/src/OpenFOAM/containers/Lists/List/UListI.H index 93f6a1788c..183b5e6893 100644 --- a/src/OpenFOAM/containers/Lists/List/UListI.H +++ b/src/OpenFOAM/containers/Lists/List/UListI.H @@ -27,7 +27,6 @@ License \*---------------------------------------------------------------------------*/ #include "error.H" -#include "pTraits.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/Lists/policy/ListPolicy.H b/src/OpenFOAM/containers/Lists/policy/ListPolicy.H index 7cf2711415..aa63fc7448 100644 --- a/src/OpenFOAM/containers/Lists/policy/ListPolicy.H +++ b/src/OpenFOAM/containers/Lists/policy/ListPolicy.H @@ -31,10 +31,9 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef ListPolicy_H -#define ListPolicy_H +#ifndef Foam_ListPolicy_H +#define Foam_ListPolicy_H -#include "label.H" #include // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -43,9 +42,9 @@ namespace Foam { // Forward Declarations +class keyType; class word; class wordRe; -class keyType; namespace Detail { @@ -58,11 +57,11 @@ namespace ListPolicy // // Default definition: 10 template -struct short_length : std::integral_constant {}; +struct short_length : std::integral_constant {}; -// Could override on a per-type basis +// Can override on a per-type basis // Eg, -// template<> struct short_length