From c8c015ddb8f3399e5684dde2daadde1cd94bbb1e Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Fri, 15 Oct 2021 15:14:51 +0100 Subject: [PATCH 1/2] fvMesh: Standardised names of non-const geometry access methods --- .../fvMeshDistribute/fvMeshDistribute.C | 4 ++-- src/finiteVolume/fvMesh/fvMesh.H | 23 +++++++++++-------- src/finiteVolume/fvMesh/fvMeshGeometry.C | 17 +++++++++++--- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C index 472449ff74..fbf6d58560 100644 --- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C +++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C @@ -1691,8 +1691,8 @@ Foam::autoPtr Foam::fvMeshDistribute::receiveMesh domainMesh.addFvPatches(patches, false); //*** Set the old-time volumes if present - // domainMesh.setV0().field() = V0; - // domainMesh.setV00().field() = V00; + // domainMesh.V0Ref().field() = V0; + // domainMesh.V00Ref().field() = V00; // Construct zones List pZonePtrs(pointZoneNames.size()); diff --git a/src/finiteVolume/fvMesh/fvMesh.H b/src/finiteVolume/fvMesh/fvMesh.H index 5e3fa2ceb9..4beb987db7 100644 --- a/src/finiteVolume/fvMesh/fvMesh.H +++ b/src/finiteVolume/fvMesh/fvMesh.H @@ -308,13 +308,19 @@ public: //- Return old-time cell volumes const DimensionedField& V0() const; + //- Access old-time cell volumes + DimensionedField& V0Ref(); + //- Return old-old-time cell volumes const DimensionedField& V00() const; + //- Access old-old-time cell volumes + DimensionedField& V00Ref(); + //- Return sub-cycle cell volumes tmp> Vsc() const; - //- Return sub-cycl old-time cell volumes + //- Return sub-cycle old-time cell volumes tmp> Vsc0() const; //- Return cell face area vectors @@ -323,9 +329,6 @@ public: //- Return cell face area magnitudes const surfaceScalarField& magSf() const; - //- Return cell face motion fluxes - const surfaceScalarField& phi() const; - //- Return cell centres as volVectorField const volVectorField& C() const; @@ -335,6 +338,12 @@ public: //- Return face deltas as surfaceVectorField tmp delta() const; + //- Return cell face motion fluxes + const surfaceScalarField& phi() const; + + //- Access cell face motion fluxes + surfaceScalarField& phiRef(); + //- Return a labelType of valid component indicators // 1 : valid (solved) // -1 : invalid (not solved) @@ -390,12 +399,6 @@ public: // these fvPatches. void removeFvBoundary(); - //- Return cell face motion fluxes - surfaceScalarField& setPhi(); - - //- Return old-time cell volumes - DimensionedField& setV0(); - // Write diff --git a/src/finiteVolume/fvMesh/fvMeshGeometry.C b/src/finiteVolume/fvMesh/fvMeshGeometry.C index 1769ccfcab..144239c0af 100644 --- a/src/finiteVolume/fvMesh/fvMeshGeometry.C +++ b/src/finiteVolume/fvMesh/fvMeshGeometry.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -226,7 +226,7 @@ const Foam::volScalarField::Internal& Foam::fvMesh::V0() const } -Foam::volScalarField::Internal& Foam::fvMesh::setV0() +Foam::volScalarField::Internal& Foam::fvMesh::V0Ref() { if (!V0Ptr_) { @@ -267,6 +267,17 @@ const Foam::volScalarField::Internal& Foam::fvMesh::V00() const } +Foam::volScalarField::Internal& Foam::fvMesh::V00Ref() +{ + if (!V00Ptr_) + { + V00(); + } + + return *V00Ptr_; +} + + Foam::tmp Foam::fvMesh::Vsc() const { @@ -429,7 +440,7 @@ const Foam::surfaceScalarField& Foam::fvMesh::phi() const } -Foam::surfaceScalarField& Foam::fvMesh::setPhi() +Foam::surfaceScalarField& Foam::fvMesh::phiRef() { if (!phiPtr_) { From 7266aa872877d1df739cd7603e94fe5b5d39bfd9 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Wed, 20 Oct 2021 12:33:08 +0100 Subject: [PATCH 2/2] GeometricFieldFunctions: Added cmptMag function --- src/OpenFOAM/dimensionSet/dimensionSet.C | 8 +++++++- src/OpenFOAM/dimensionSet/dimensionSet.H | 4 +++- .../DimensionedField/DimensionedFieldFunctions.C | 5 ++++- .../DimensionedField/DimensionedFieldFunctions.H | 4 +++- .../GeometricField/GeometricFieldFunctions.C | 4 +++- .../GeometricField/GeometricFieldFunctions.H | 4 +++- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/OpenFOAM/dimensionSet/dimensionSet.C b/src/OpenFOAM/dimensionSet/dimensionSet.C index e5519d2698..811c9e83a7 100644 --- a/src/OpenFOAM/dimensionSet/dimensionSet.C +++ b/src/OpenFOAM/dimensionSet/dimensionSet.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -272,6 +272,12 @@ Foam::dimensionSet Foam::cmptDivide } +Foam::dimensionSet Foam::cmptMag(const dimensionSet& ds) +{ + return ds; +} + + Foam::dimensionSet Foam::pow(const dimensionSet& ds, const scalar p) { dimensionSet dimPow diff --git a/src/OpenFOAM/dimensionSet/dimensionSet.H b/src/OpenFOAM/dimensionSet/dimensionSet.H index 33c158ae07..96cc28c7ba 100644 --- a/src/OpenFOAM/dimensionSet/dimensionSet.H +++ b/src/OpenFOAM/dimensionSet/dimensionSet.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -63,6 +63,7 @@ dimensionSet max(const dimensionSet&, const dimensionSet&); dimensionSet min(const dimensionSet&, const dimensionSet&); dimensionSet cmptMultiply(const dimensionSet&, const dimensionSet&); dimensionSet cmptDivide(const dimensionSet&, const dimensionSet&); +dimensionSet cmptMag(const dimensionSet&); dimensionSet pow(const dimensionSet&, const scalar); dimensionSet pow(const dimensionSet&, const dimensionedScalar&); @@ -346,6 +347,7 @@ public: const dimensionSet&, const dimensionSet& ); + friend dimensionSet cmptMag(const dimensionSet&); friend dimensionSet pow(const dimensionSet&, const scalar); friend dimensionSet pow(const dimensionSet&, const dimensionedScalar&); diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.C b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.C index c943a1f9a1..5d751e7737 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.C +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -276,6 +276,9 @@ cmptAv(const tmp>& tdf) return CmptAv; } +UNARY_FUNCTION(Type, Type, cmptMag, cmptMag); + + #define UNARY_REDUCTION_FUNCTION(returnType, func, dfunc) \ \ template \ diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.H b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.H index d88c3da384..977c7b8978 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.H +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -99,6 +99,8 @@ tmp > cmptAv(const tmp>& tdf); +UNARY_FUNCTION(Type, Type, cmptMag, cmptMag); + #define UNARY_REDUCTION_FUNCTION(returnType, func, dfunc) \ \ diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C index 54cc6c47d5..492ad18341 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -422,6 +422,8 @@ cmptAv(const tmp>& tgf) return CmptAv; } +UNARY_FUNCTION(Type, Type, cmptMag, cmptMag); + #define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc) \ \ diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.H index fefeca2db6..c67bba52a2 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -211,6 +211,8 @@ tmp > cmptAv(const tmp>& tgf); +UNARY_FUNCTION(Type, Type, cmptMag, cmptMag); + #define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc) \ \