diff --git a/META-INFO/api-info b/META-INFO/api-info index b1f4c5a83a..3e99571432 100644 --- a/META-INFO/api-info +++ b/META-INFO/api-info @@ -1,2 +1,2 @@ -api=2501 +api=2502 patch=0 diff --git a/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H b/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H index 34b26b49ed..50e8027620 100644 --- a/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H +++ b/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2023 OpenCFD Ltd. + Copyright (C) 2018-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,74 +39,23 @@ namespace Foam { template -void evaluateConstraintTypes(GeometricField& fld) +void evaluateConstraintTypes +( + GeometricField& fld +) { - auto& bfld = fld.boundaryFieldRef(); - - const UPstream::commsTypes commsType = UPstream::defaultCommsType; - - if + fld.boundaryFieldRef().evaluate_if ( - commsType == UPstream::commsTypes::buffered - || commsType == UPstream::commsTypes::nonBlocking - ) - { - const label startOfRequests = UPstream::nRequests(); - - for (auto& pfld : bfld) + [](const auto& pfld) -> bool { - if + return ( pfld.type() == pfld.patch().patch().type() && polyPatch::constraintType(pfld.patch().patch().type()) - ) - { - pfld.initEvaluate(commsType); - } - } - - // Wait for outstanding requests (non-blocking) - UPstream::waitRequests(startOfRequests); - - for (auto& pfld : bfld) - { - if - ( - pfld.type() == pfld.patch().patch().type() - && polyPatch::constraintType(pfld.patch().patch().type()) - ) - { - pfld.evaluate(commsType); - } - } - } - else if (commsType == UPstream::commsTypes::scheduled) - { - const lduSchedule& patchSchedule = - fld.mesh().globalData().patchSchedule(); - - for (const auto& schedEval : patchSchedule) - { - const label patchi = schedEval.patch; - auto& pfld = bfld[patchi]; - - if - ( - pfld.type() == pfld.patch().patch().type() - && polyPatch::constraintType(pfld.patch().patch().type()) - ) - { - if (schedEval.init) - { - pfld.initEvaluate(commsType); - } - else - { - pfld.evaluate(commsType); - } - } - } - } + ); + }, + UPstream::defaultCommsType + ); } diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H index 28648b9893..65686daeda 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H @@ -373,6 +373,33 @@ public: Field&& iField ); + //- Return tmp field (NO_READ, NO_WRITE) + //- from name, mesh, dimensions, primitive field (tmp). + //- [Takes current timeName from the mesh registry]. + // For LEGACY_REGISTER, registration is determined by + // objectRegistry::is_cacheTemporaryObject(). + static tmp> New + ( + const word& name, + IOobjectOption::registerOption regOpt, + const Mesh& mesh, + const dimensionSet& dims, + const tmp>& tfield + ); + + //- Return tmp field (NO_READ, NO_WRITE) + //- from name, mesh, dimensions, primitive field (tmp). + //- [Takes current timeName from the mesh registry]. + // Registration/persistence determined by + // objectRegistry::is_cacheTemporaryObject(). + static tmp> New + ( + const word& name, + const Mesh& mesh, + const dimensionSet& dims, + const tmp>& tfield + ); + //- Return tmp field (NO_READ, NO_WRITE) //- from name, mesh, dimensions. //- [Takes current timeName from the mesh registry]. diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldNew.C b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldNew.C index c8f2e12f1d..61a1713c56 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldNew.C +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldNew.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022-2024 OpenCFD Ltd. + Copyright (C) 2022-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -163,6 +163,49 @@ Foam::DimensionedField::New } +template +Foam::tmp> +Foam::DimensionedField::New +( + const word& name, + IOobjectOption::registerOption regOpt, + const Mesh& mesh, + const dimensionSet& dims, + const tmp>& tfield +) +{ + return DimensionedField::New_impl + ( + regOpt, + name, + mesh, + dims, + tfield + ); +} + + +template +Foam::tmp> +Foam::DimensionedField::New +( + const word& name, + const Mesh& mesh, + const dimensionSet& dims, + const tmp>& tfield +) +{ + return DimensionedField::New_impl + ( + IOobjectOption::LEGACY_REGISTER, + name, + mesh, + dims, + tfield + ); +} + + template Foam::tmp> Foam::DimensionedField::New diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C index 059560a01d..a8a47aba33 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017,2022 OpenFOAM Foundation - Copyright (C) 2016-2024 OpenCFD Ltd. + Copyright (C) 2016-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -64,6 +64,8 @@ bool Foam::GeometricBoundaryField::checkConsistency //Note: areaFields (finiteArea) do not have manipulatedMatrix() flag. TBD. //boolList oldManipulated(this->size()); + label nEvaluated(0); + for (auto& pfld : bfld) { if (isA(pfld)) @@ -72,19 +74,24 @@ bool Foam::GeometricBoundaryField::checkConsistency oldUpdated[patchi] = pfld.updated(); oldBfld[patchi] = pfld; //oldManipulated[patchi] = pfld.manipulatedMatrix(); + ++nEvaluated; } } + if (!nEvaluated) return true; // Early termination // Re-evaluate { const label startOfRequests = UPstream::nRequests(); + nEvaluated = 0; + for (auto& pfld : bfld) { if (isA(pfld)) { pfld.initEvaluate(UPstream::commsTypes::nonBlocking); + ++nEvaluated; } } @@ -96,13 +103,15 @@ bool Foam::GeometricBoundaryField::checkConsistency if (isA(pfld)) { pfld.evaluate(UPstream::commsTypes::nonBlocking); + if (--nEvaluated == 0) break; // Early termination } } } // Check - bool ok = true; + bool allOk(true); + for (auto& pfld : bfld) { if (isA(pfld)) @@ -110,16 +119,23 @@ bool Foam::GeometricBoundaryField::checkConsistency const label patchi = pfld.patch().index(); const auto& oldPfld = oldBfld[patchi]; - forAll(pfld, facei) + bool localOk(true); + + if (allOk) { - if (mag(pfld[facei]-oldPfld[facei]) > tol) + // Only check once + forAll(pfld, facei) { - ok = false; - break; + if (mag(pfld[facei]-oldPfld[facei]) > tol) + { + allOk = false; + localOk = false; + break; + } } } - if (!ok) + if (!localOk) { if (doExit) { @@ -133,7 +149,7 @@ bool Foam::GeometricBoundaryField::checkConsistency << ". Average of evaluated field = " << average(pfld) << ". Difference:" << average(pfld-oldPfld) - << ". Tolerance:" << tol + << ". Tolerance:" << tol << endl << exit(FatalError); } else @@ -148,25 +164,13 @@ bool Foam::GeometricBoundaryField::checkConsistency << ". Average of evaluated field = " << average(pfld) << ". Difference:" << average(pfld-oldPfld) - << ". Tolerance:" << tol - << endl; - - // Skip other patches - break; + << ". Tolerance:" << tol << endl; } } - } - } - // Restore bfld, updated - for (auto& pfld : bfld) - { - if (isA(pfld)) - { - const label patchi = pfld.patch().index(); + // Restore bfld, updated pfld.setUpdated(oldUpdated[patchi]); - Field& vals = pfld; - vals = std::move(oldBfld[patchi]); + static_cast&>(pfld) = std::move(oldBfld[patchi]); //pfld.setManipulated(oldManipulated[patchi]); } } @@ -176,10 +180,10 @@ bool Foam::GeometricBoundaryField::checkConsistency const auto& pfld0 = this->operator[](0); PoutInFunction << " Result of checking for field " - << pfld0.internalField().name() << " : " << ok << endl; + << pfld0.internalField().name() << " : " << allOk << endl; } - return ok; + return allOk; } @@ -626,6 +630,7 @@ void Foam::GeometricBoundaryField::evaluate_if || commsType == UPstream::commsTypes::nonBlocking ) { + label nEvaluated(0); const label startOfRequests = UPstream::nRequests(); for (auto& pfld : *this) @@ -633,17 +638,21 @@ void Foam::GeometricBoundaryField::evaluate_if if (pred(pfld)) { pfld.initEvaluate(commsType); + ++nEvaluated; } } // Wait for outstanding requests (non-blocking) UPstream::waitRequests(startOfRequests); + if (!nEvaluated) return; // Early termination + for (auto& pfld : *this) { if (pred(pfld)) { pfld.evaluate(commsType); + if (--nEvaluated == 0) break; // Early termination } } } @@ -778,81 +787,25 @@ void Foam::GeometricBoundaryField::evaluateCoupled const UPstream::commsTypes commsType ) { - // Alternative (C++14) - // - // this->evaluate_if - // ( - // [](const auto& pfld) -> bool - // { - // const auto* cpp = isA(pfld.patch()); - // return (cpp && cpp->coupled()); - // }, - // commsType - // ); - - // DebugInFunction << nl; - - if - ( - commsType == UPstream::commsTypes::buffered - || commsType == UPstream::commsTypes::nonBlocking - ) + if constexpr (std::is_void_v) { - const label startOfRequests = UPstream::nRequests(); - - for (auto& pfld : *this) - { - const auto* cpp = isA(pfld.patch()); - - if (cpp && cpp->coupled()) - { - pfld.initEvaluate(commsType); - } - } - - // Wait for outstanding requests (non-blocking) - UPstream::waitRequests(startOfRequests); - - for (auto& pfld : *this) - { - const auto* cpp = isA(pfld.patch()); - - if (cpp && cpp->coupled()) - { - pfld.evaluate(commsType); - } - } - } - else if (commsType == UPstream::commsTypes::scheduled) - { - const lduSchedule& patchSchedule = - bmesh_.mesh().globalData().patchSchedule(); - - for (const auto& schedEval : patchSchedule) - { - const label patchi = schedEval.patch; - auto& pfld = (*this)[patchi]; - - const auto* cpp = isA(pfld.patch()); - - if (cpp && cpp->coupled()) - { - if (schedEval.init) - { - pfld.initEvaluate(commsType); - } - else - { - pfld.evaluate(commsType); - } - } - } + this->evaluate_if + ( + [](const auto& pfld) { return pfld.coupled(); }, + commsType + ); } else { - FatalErrorInFunction - << "Unsupported communications type " << int(commsType) << nl - << exit(FatalError); + this->evaluate_if + ( + [](const auto& pfld) -> bool + { + const auto* cpp = isA(pfld.patch()); + return (cpp && cpp->coupled()); + }, + commsType + ); } } diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.H index 0fb33d5ce1..bfd6b3f775 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.H @@ -205,8 +205,12 @@ public: const UPstream::commsTypes commsType = UPstream::defaultCommsType ); - //- Evaluate boundary conditions on coupled patches of given type. - //- Uses specified or default comms. + //- Evaluate boundary conditions on coupled patches of the given type, + //- using specified or default comms. + // + // \tparam CoupledPatchType The coupled \b patch type that should + // be evaluated. For a \c void type, + // all coupled patch fields will be evaluated. template void evaluateCoupled ( diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index 7667b78435..c2ae24ad0e 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -63,8 +63,10 @@ void Foam::GeometricField::readFields if (dict.readIfPresent("referenceLevel", refLevel)) { - Field::operator+=(refLevel); + // Add to internal (primitive) field + this->field() += refLevel; + // Add to boundary fields forAll(boundaryField_, patchi) { boundaryField_[patchi] == boundaryField_[patchi] + refLevel; @@ -409,7 +411,7 @@ Foam::GeometricField::GeometricField boundaryField_(mesh.boundary(), *this, patchFieldType) { DebugInFunction - << "Copy construct from internal field" << nl << this->info() << endl; + << "Copy construct from primitive field" << nl << this->info() << endl; readIfPresent(); } @@ -430,7 +432,28 @@ Foam::GeometricField::GeometricField boundaryField_(mesh.boundary(), *this, patchFieldType) { DebugInFunction - << "Move construct from internal field" << nl << this->info() << endl; + << "Move construct from primitive field" << nl << this->info() << endl; + + readIfPresent(); +} + + +template class PatchField, class GeoMesh> +Foam::GeometricField::GeometricField +( + const IOobject& io, + const Mesh& mesh, + const dimensionSet& dims, + const tmp>& tfield, + const word& patchFieldType +) +: + Internal(io, mesh, dims, tfield), + timeIndex_(this->time().timeIndex()), + boundaryField_(mesh.boundary(), *this, patchFieldType) +{ + DebugInFunction + << "Construct from tmp primitive field" << nl << this->info() << endl; readIfPresent(); } @@ -1391,10 +1414,7 @@ void Foam::GeometricField::operator= // Make sure any e.g. jump-cyclic are updated. boundaryFieldRef().evaluate_if ( - [](const auto& pfld) -> bool - { - return pfld.constraintOverride(); - } + [](const auto& pfld) { return pfld.constraintOverride(); } ); } @@ -1436,10 +1456,7 @@ void Foam::GeometricField::operator= // Make sure any e.g. jump-cyclic are updated. boundaryFieldRef().evaluate_if ( - [](const auto& pfld) -> bool - { - return pfld.constraintOverride(); - } + [](const auto& pfld) { return pfld.constraintOverride(); } ); } @@ -1456,10 +1473,7 @@ void Foam::GeometricField::operator= // Make sure any e.g. jump-cyclic are updated. boundaryFieldRef().evaluate_if ( - [](const auto& pfld) -> bool - { - return pfld.constraintOverride(); - } + [](const auto& pfld) { return pfld.constraintOverride(); } ); } @@ -1484,10 +1498,7 @@ void Foam::GeometricField::operator== // Make sure any e.g. jump-cyclic are updated. boundaryFieldRef().evaluate_if ( - [](const auto& pfld) -> bool - { - return pfld.constraintOverride(); - } + [](const auto& pfld) { return pfld.constraintOverride(); } ); } @@ -1504,10 +1515,7 @@ void Foam::GeometricField::operator== // Make sure any e.g. jump-cyclic are updated. boundaryFieldRef().evaluate_if ( - [](const auto& pfld) -> bool - { - return pfld.constraintOverride(); - } + [](const auto& pfld) { return pfld.constraintOverride(); } ); } @@ -1527,10 +1535,7 @@ void Foam::GeometricField::operator op \ \ boundaryFieldRef().evaluate_if \ ( \ - [](const auto& pfld) -> bool \ - { \ - return pfld.constraintOverride(); \ - } \ + [](const auto& pfld) { return pfld.constraintOverride(); } \ ); \ } \ \ @@ -1545,10 +1550,7 @@ void Foam::GeometricField::operator op \ \ boundaryFieldRef().evaluate_if \ ( \ - [](const auto& pfld) -> bool \ - { \ - return pfld.constraintOverride(); \ - } \ + [](const auto& pfld) { return pfld.constraintOverride(); } \ ); \ } \ \ @@ -1563,10 +1565,7 @@ void Foam::GeometricField::operator op \ \ boundaryFieldRef().evaluate_if \ ( \ - [](const auto& pfld) -> bool \ - { \ - return pfld.constraintOverride(); \ - } \ + [](const auto& pfld) { return pfld.constraintOverride(); } \ ); \ } diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H index fd5bf40049..2b6614bf88 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H @@ -251,7 +251,7 @@ public: const PtrList>& ptfl ); - //- Move construct from internal field and a patch list to clone + //- Construct from internal field (tmp) and a patch list to clone GeometricField ( const IOobject& io, @@ -273,7 +273,7 @@ public: const PtrList>& ptfl ); - //- Copy construct from internal field, with specified patch type + //- Copy construct from primitive field, with specified patch type GeometricField ( const IOobject& io, @@ -283,7 +283,7 @@ public: const word& patchFieldType = PatchField::calculatedType() ); - //- Move construct from internal field, with specified patch type + //- Move construct from primitive field, with specified patch type GeometricField ( const IOobject& io, @@ -293,7 +293,17 @@ public: const word& patchFieldType = PatchField::calculatedType() ); - //- Copy construct from components + //- Construct from primitive field (tmp), with specified patch type + GeometricField + ( + const IOobject& io, + const Mesh& mesh, + const dimensionSet& dims, + const tmp>& tfield, + const word& patchFieldType = PatchField::calculatedType() + ); + + //- Copy construct from primitive field and a patch list to clone GeometricField ( const IOobject& io, @@ -303,7 +313,7 @@ public: const PtrList>& ptfl ); - //- Move construct from internal field and a patch list to clone + //- Move construct from primitive field and a patch list to clone GeometricField ( const IOobject& io, @@ -319,7 +329,7 @@ public: const IOobject& io, const Mesh& mesh, const dimensionSet& dims, - const tmp>& tiField, + const tmp>& tfield, const PtrList>& ptfl ); @@ -508,6 +518,37 @@ public: const word& patchFieldType = PatchField::calculatedType() ); + //- Return tmp field (NO_READ, NO_WRITE) + //- from name, mesh, dimensions, tmp of primitive field + //- and patch type. + //- [Takes current timeName from the mesh registry]. + // For LEGACY_REGISTER, registration is determined by + // objectRegistry::is_cacheTemporaryObject(). + static tmp> New + ( + const word& name, + IOobjectOption::registerOption regOpt, + const Mesh& mesh, + const dimensionSet& dims, + const tmp>& tfield, + const word& patchFieldType = PatchField::calculatedType() + ); + + //- Return tmp field (NO_READ, NO_WRITE) + //- from name, mesh, dimensions, tmp of primitive field + //- and patch type. + //- [Takes current timeName from the mesh registry]. + // Registration/persistence determined by + // objectRegistry::is_cacheTemporaryObject(). + static tmp> New + ( + const word& name, + const Mesh& mesh, + const dimensionSet& dims, + const tmp>& tfield, + const word& patchFieldType = PatchField::calculatedType() + ); + //- Return tmp field (NO_READ, NO_WRITE) //- from name, mesh, dimensions, copy of internal field contents //- and patch list to clone. diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldNew.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldNew.C index 138d14d3b0..94521bb085 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldNew.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2019-2024 OpenCFD Ltd. + Copyright (C) 2019-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -215,6 +215,53 @@ Foam::GeometricField::New } +template class PatchField, class GeoMesh> +Foam::tmp> +Foam::GeometricField::New +( + const word& name, + IOobjectOption::registerOption regOpt, + const Mesh& mesh, + const dimensionSet& dims, + const tmp>& tfield, + const word& patchFieldType +) +{ + return GeometricField::New_impl + ( + regOpt, + name, + mesh, + dims, + tfield, + patchFieldType + ); +} + + +template class PatchField, class GeoMesh> +Foam::tmp> +Foam::GeometricField::New +( + const word& name, + const Mesh& mesh, + const dimensionSet& dims, + const tmp>& tfield, + const word& patchFieldType +) +{ + return GeometricField::New_impl + ( + IOobjectOption::LEGACY_REGISTER, + name, + mesh, + dims, + tfield, + patchFieldType + ); +} + + template class PatchField, class GeoMesh> Foam::tmp> Foam::GeometricField::New diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.C index 43c5d18429..a8c4da3b13 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/basicSymmetry/basicSymmetryPointPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -87,20 +88,27 @@ void Foam::basicSymmetryPointPatchField::evaluate const Pstream::commsTypes ) { - const vectorField& nHat = this->patch().pointNormals(); + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type : no-op + } + else + { + const vectorField& nHat = this->patch().pointNormals(); - tmp> tvalues = - ( + const Field pif(this->patchInternalField()); + + // Could write as loop instead... + tmp> tvalues ( - this->patchInternalField() - + transform(I - 2.0*sqr(nHat), this->patchInternalField()) - )/2.0 - ); + 0.5*(pif + transform(I - 2.0*sqr(nHat), pif)) + ); - // Get internal field to insert values into - Field& iF = const_cast&>(this->primitiveField()); + // Get internal field to insert values into + auto& iF = const_cast&>(this->primitiveField()); - this->setInInternalField(iF, tvalues()); + this->setInInternalField(iF, tvalues()); + } } diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.C index 686033987e..166f6172c1 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.C @@ -27,7 +27,6 @@ License \*---------------------------------------------------------------------------*/ #include "fixedValuePointPatchField.H" -#include "boolList.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchField.C index da2604590c..2126c25863 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclicSlip/cyclicSlipPointPatchField.C @@ -84,20 +84,27 @@ Foam::cyclicSlipPointPatchField::cyclicSlipPointPatchField template void Foam::cyclicSlipPointPatchField::evaluate(const Pstream::commsTypes) { - const vectorField& nHat = this->patch().pointNormals(); + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type : no-op + } + else + { + const vectorField& nHat = this->patch().pointNormals(); - tmp> tvalues = - ( + const Field pif(this->patchInternalField()); + + // Could write as loop instead... + tmp> tvalues ( - this->patchInternalField() - + transform(I - 2.0*sqr(nHat), this->patchInternalField()) - )/2.0 - ); + 0.5*(pif + transform(I - 2.0*sqr(nHat), pif)) + ); - // Get internal field to insert values into - Field& iF = const_cast&>(this->primitiveField()); + // Get internal field to insert values into + auto& iF = const_cast&>(this->primitiveField()); - this->setInInternalField(iF, tvalues()); + this->setInInternalField(iF, tvalues()); + } } diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicPointPatchField.C index 732371d0c0..ee2ea085b9 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicPointPatchField.C @@ -91,20 +91,27 @@ void Foam::nonuniformTransformCyclicPointPatchField::evaluate const Pstream::commsTypes ) { - const vectorField& nHat = this->patch().pointNormals(); + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type : no-op + } + else + { + const vectorField& nHat = this->patch().pointNormals(); - tmp> tvalues = - ( + const Field pif(this->patchInternalField()); + + // Could write as loop instead... + tmp> tvalues ( - this->patchInternalField() - + transform(I - 2.0*sqr(nHat), this->patchInternalField()) - )/2.0 - ); + 0.5*(pif + transform(I - 2.0*sqr(nHat), pif)) + ); - // Get internal field to insert values into - Field& iF = const_cast&>(this->primitiveField()); + // Get internal field to insert values into + auto& iF = const_cast&>(this->primitiveField()); - this->setInInternalField(iF, tvalues()); + this->setInInternalField(iF, tvalues()); + } } diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/symmetryPlane/symmetryPlanePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/symmetryPlane/symmetryPlanePointPatchField.C index 9eac7d0329..7dd6bcdf71 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/symmetryPlane/symmetryPlanePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/symmetryPlane/symmetryPlanePointPatchField.C @@ -106,20 +106,27 @@ void Foam::symmetryPlanePointPatchField::evaluate const Pstream::commsTypes ) { - vector nHat = symmetryPlanePatch_.n(); + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type : no-op + } + else + { + const symmTensor rot(I - 2.0*sqr(symmetryPlanePatch_.n())); - tmp> tvalues = - ( + const Field pif(this->patchInternalField()); + + // Could write as loop instead... + tmp> tvalues ( - this->patchInternalField() - + transform(I - 2.0*sqr(nHat), this->patchInternalField()) - )/2.0 - ); + 0.5*(pif + transform(rot, pif)) + ); - // Get internal field to insert values into - Field& iF = const_cast&>(this->primitiveField()); + // Get internal field to insert values into + auto& iF = const_cast&>(this->primitiveField()); - this->setInInternalField(iF, tvalues()); + this->setInInternalField(iF, tvalues()); + } } diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.C index 6ec8dce45e..457d195c90 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,7 +29,6 @@ License #include "wedgePointPatchField.H" #include "transformField.H" - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template @@ -101,17 +101,28 @@ Foam::wedgePointPatchField::wedgePointPatchField template void Foam::wedgePointPatchField::evaluate(const Pstream::commsTypes) { - // In order to ensure that the wedge patch is always flat, take the - // normal vector from the first point - const vector& nHat = this->patch().pointNormals()[0]; + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type : no-op + } + else + { + // In order to ensure that the wedge patch is always flat, take the + // normal vector from the first point - tmp> tvalues = - transform(I - nHat*nHat, this->patchInternalField()); + const symmTensor rot(I - 2.0*sqr(this->patch().pointNormals()[0])); - // Get internal field to insert values into - Field& iF = const_cast&>(this->primitiveField()); + // Could write as loop instead... + tmp> tvalues + ( + transform(rot, this->patchInternalField()) + ); - this->setInInternalField(iF, tvalues()); + // Get internal field to insert values into + auto& iF = const_cast&>(this->primitiveField()); + + this->setInInternalField(iF, tvalues()); + } } diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C index a68cec5e43..85ce07b2e5 100644 --- a/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -88,13 +89,22 @@ void Foam::fixedNormalSlipPointPatchField::evaluate const Pstream::commsTypes ) { - tmp> tvalues = - transform(I - n_*n_, this->patchInternalField()); + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type : no-op + } + else + { + tmp> tvalues + ( + transform(I - n_*n_, this->patchInternalField()) + ); - // Get internal field to insert values into - Field& iF = const_cast&>(this->primitiveField()); + // Get internal field to insert values into + auto& iF = const_cast&>(this->primitiveField()); - this->setInInternalField(iF, tvalues()); + this->setInInternalField(iF, tvalues()); + } } diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H index 2c59c5c9f3..669c1f48d3 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H @@ -167,13 +167,13 @@ public: } //- Return processor number - int myProcNo() const + int myProcNo() const noexcept { return procPolyPatch_.myProcNo(); } //- Return neighbour processor number - int neighbProcNo() const + int neighbProcNo() const noexcept { return procPolyPatch_.neighbProcNo(); } @@ -191,13 +191,13 @@ public: } //- Return the underlying processorPolyPatch - const processorPolyPatch& procPolyPatch() const + const processorPolyPatch& procPolyPatch() const noexcept { return procPolyPatch_; } //- Return mesh points in the correct order for the receiving side - const labelList& reverseMeshPoints() const + const labelList& reverseMeshPoints() const noexcept { return reverseMeshPoints_; } diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.H index a21513d04f..8692ebde18 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.H @@ -34,8 +34,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef wedgePointPatch_H -#define wedgePointPatch_H +#ifndef Foam_wedgePointPatch_H +#define Foam_wedgePointPatch_H #include "facePointPatch.H" #include "wedgePolyPatch.H" @@ -53,9 +53,9 @@ class wedgePointPatch : public facePointPatch { - // Private data + // Private Data - //- Local reference cast into the symmetryPlane patch + //- Local reference cast into the wedgePolyPatch patch const wedgePolyPatch& wedgePolyPatch_; @@ -120,8 +120,8 @@ public: pointConstraint& ) const; - //- Return symmetry plane normal - const vector& n() const + //- Return the normal to the patch + const vector& n() const noexcept { return wedgePolyPatch_.n(); } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.H index 69313162ae..cb9e42ef71 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.H @@ -34,8 +34,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef wedgePolyPatch_H -#define wedgePolyPatch_H +#ifndef Foam_wedgePolyPatch_H +#define Foam_wedgePolyPatch_H #include "polyPatch.H" @@ -52,7 +52,7 @@ class wedgePolyPatch : public polyPatch { - // Private data + // Private Data //- Axis of the wedge vector axis_; @@ -173,45 +173,27 @@ public: } - // Member functions + // Member Functions - // Access + // Access - //- Return axis of the wedge - const vector& axis() const - { - return axis_; - } + //- Return axis of the wedge + const vector& axis() const noexcept { return axis_; } - //- Return plane normal between the wedge boundaries - const vector& centreNormal() const - { - return centreNormal_; - } + //- Return plane normal between the wedge boundaries + const vector& centreNormal() const noexcept { return centreNormal_; } - //- Return the normal to the patch - const vector& n() const - { - return n_; - } + //- Return the normal to the patch + const vector& n() const noexcept { return n_; } - //- Return the cosine of the wedge angle - scalar cosAngle() const - { - return cosAngle_; - } + //- Return the cosine of the wedge angle + scalar cosAngle() const noexcept { return cosAngle_; } - //- Return face transformation tensor - const tensor& faceT() const - { - return faceT_; - } + //- Return face transformation tensor + const tensor& faceT() const noexcept { return faceT_; } - //- Return neighbour-cell transformation tensor - const tensor& cellT() const - { - return cellT_; - } + //- Return neighbour-cell transformation tensor + const tensor& cellT() const noexcept { return cellT_; } }; diff --git a/src/finiteArea/Make/files b/src/finiteArea/Make/files index c318012d21..94be44a0e1 100644 --- a/src/finiteArea/Make/files +++ b/src/finiteArea/Make/files @@ -45,7 +45,6 @@ $(faPatchFields)/faPatchField/faPatchFieldBase.C $(faPatchFields)/faPatchField/faPatchFields.C basicFaPatchFields = $(faPatchFields)/basic -$(basicFaPatchFields)/basicSymmetry/basicSymmetryFaPatchFields.C $(basicFaPatchFields)/calculated/calculatedFaPatchFields.C $(basicFaPatchFields)/extrapolatedCalculated/extrapolatedCalculatedFaPatchFields.C $(basicFaPatchFields)/coupled/coupledFaPatchFields.C diff --git a/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.C b/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.C index 8c8e70e661..40ee9e49ed 100644 --- a/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.C +++ b/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.C @@ -93,16 +93,12 @@ Foam::wedgeFaPatch::wedgeFaPatch << this->name() << exit(FatalError); } - const auto* wedgePtr = isA + wedgePolyPatchPtr_ = isA ( bm.mesh().mesh().boundaryMesh()[ngbPolyPatchIndex()] ); - if (wedgePtr) - { - wedgePolyPatchPtr_ = wedgePtr; - } - else + if (!wedgePolyPatchPtr_) { FatalErrorInFunction << "Neighbour polyPatch is not of type " diff --git a/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.H b/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.H index 5c981d4df5..9bc011d3c1 100644 --- a/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.H +++ b/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.H @@ -77,7 +77,9 @@ public: //- Runtime type information TypeName("wedge"); - //- Construct from dictionary + //- Construct from dictionary. + // Fatal if ngbPolyPatchIndex is not defined + // or does not correspond to a wedgePolyPatch wedgeFaPatch ( const word& name, @@ -97,25 +99,25 @@ public: // Access //- Return axis of the wedge - const vector& axis() const + const vector& axis() const noexcept { return wedgePolyPatchPtr_->axis(); } //- Return plane normal between the wedge boundaries - const vector& centreNormal() const + const vector& centreNormal() const noexcept { return wedgePolyPatchPtr_->centreNormal(); } //- Return face transformation tensor - const tensor& edgeT() const + const tensor& edgeT() const noexcept { return wedgePolyPatchPtr_->faceT(); } //- Return neighbour-cell transformation tensor - const tensor& faceT() const + const tensor& faceT() const noexcept { return wedgePolyPatchPtr_->cellT(); } diff --git a/src/finiteArea/fields/faPatchFields/basic/basicSymmetry/basicSymmetryFaPatchField.C b/src/finiteArea/fields/faPatchFields/basic/basicSymmetry/basicSymmetryFaPatchField.C index 63bab59206..3a808480e8 100644 --- a/src/finiteArea/fields/faPatchFields/basic/basicSymmetry/basicSymmetryFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/basic/basicSymmetry/basicSymmetryFaPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd + Copyright (C) 2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -85,13 +86,25 @@ template Foam::tmp> Foam::basicSymmetryFaPatchField::snGrad() const { - const vectorField nHat(this->patch().edgeNormals()); + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type : treat like zero-gradient + return tmp>::New(this->size(), Foam::zero{}); + } + else + { + tmp nHat = this->patch().edgeNormals(); - return - ( - transform(I - 2.0*sqr(nHat), this->patchInternalField()) - - this->patchInternalField() - )*(this->patch().deltaCoeffs()/2.0); + const auto& dc = this->patch().deltaCoeffs(); + + const Field pif(this->patchInternalField()); + + return + ( + (0.5*dc) + * (transform(I - 2.0*sqr(nHat), pif) - pif) + ); + } } @@ -103,14 +116,22 @@ void Foam::basicSymmetryFaPatchField::evaluate(const Pstream::commsTypes) this->updateCoeffs(); } - const vectorField nHat(this->patch().edgeNormals()); - Field::operator= - ( + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type : treat like zero-gradient + this->extrapolateInternal(); + } + else + { + tmp nHat = this->patch().edgeNormals(); + + const Field pif(this->patchInternalField()); + + Field::operator= ( - this->patchInternalField() - + transform(I - 2.0*sqr(nHat), this->patchInternalField()) - )/2.0 - ); + 0.5*(pif + transform(I - 2.0*sqr(nHat), pif)) + ); + } transformFaPatchField::evaluate(); } diff --git a/src/finiteArea/fields/faPatchFields/basic/basicSymmetry/basicSymmetryFaPatchField.H b/src/finiteArea/fields/faPatchFields/basic/basicSymmetry/basicSymmetryFaPatchField.H index 83f3c0ad89..417d21a445 100644 --- a/src/finiteArea/fields/faPatchFields/basic/basicSymmetry/basicSymmetryFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/basic/basicSymmetry/basicSymmetryFaPatchField.H @@ -143,18 +143,6 @@ public: }; -// * * * * * * * * * * * Template Specialisations * * * * * * * * * * * * * // - -template<> -tmp basicSymmetryFaPatchField::snGrad() const; - -template<> -void basicSymmetryFaPatchField::evaluate -( - const Pstream::commsTypes commsType -); - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/finiteArea/fields/faPatchFields/basic/basicSymmetry/basicSymmetryFaPatchFields.C b/src/finiteArea/fields/faPatchFields/basic/basicSymmetry/basicSymmetryFaPatchFields.C deleted file mode 100644 index 5eb0ce55dd..0000000000 --- a/src/finiteArea/fields/faPatchFields/basic/basicSymmetry/basicSymmetryFaPatchFields.C +++ /dev/null @@ -1,59 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2016-2017 Wikki Ltd -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "basicSymmetryFaPatchField.H" -#include "areaFields.H" - -// No run-time selection - -// * * * * * * * * * * * * * * * Specialisations * * * * * * * * * * * * * * // - -template<> -Foam::tmp -Foam::basicSymmetryFaPatchField::snGrad() const -{ - return tmp::New(size(), Zero); -} - - -template<> -void Foam::basicSymmetryFaPatchField::evaluate -( - const Pstream::commsTypes -) -{ - if (!updated()) - { - updateCoeffs(); - } - - scalarField::operator=(patchInternalField()); - transformFaPatchField::evaluate(); -} - - -// ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/basic/transform/transformFaPatchField.C b/src/finiteArea/fields/faPatchFields/basic/transform/transformFaPatchField.C index a5da3c9ef6..8e3c98e039 100644 --- a/src/finiteArea/fields/faPatchFields/basic/transform/transformFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/basic/transform/transformFaPatchField.C @@ -37,7 +37,7 @@ Foam::transformFaPatchField::transformFaPatchField const DimensionedField& iF ) : - faPatchField(p, iF) + faPatchField(p, iF) {} diff --git a/src/finiteArea/fields/faPatchFields/basic/transform/transformFaPatchField.H b/src/finiteArea/fields/faPatchFields/basic/transform/transformFaPatchField.H index f4515b6a59..b7c6c71731 100644 --- a/src/finiteArea/fields/faPatchFields/basic/transform/transformFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/basic/transform/transformFaPatchField.H @@ -148,12 +148,6 @@ public: }; -// * * * * * * * * * * * Template Specialisations * * * * * * * * * * * * * // - -template<> -tmp transformFaPatchField::gradientInternalCoeffs() const; - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/finiteArea/fields/faPatchFields/basic/transform/transformFaPatchFields.C b/src/finiteArea/fields/faPatchFields/basic/transform/transformFaPatchFields.C index 80e8e0bec1..910d94ecec 100644 --- a/src/finiteArea/fields/faPatchFields/basic/transform/transformFaPatchFields.C +++ b/src/finiteArea/fields/faPatchFields/basic/transform/transformFaPatchFields.C @@ -37,14 +37,4 @@ namespace Foam } -// * * * * * * * * * * * * * * * Specialisations * * * * * * * * * * * * * * // - -template<> -Foam::tmp -Foam::transformFaPatchField::gradientInternalCoeffs() const -{ - return tmp::New(size(), Zero); -} - - // ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C b/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C index deded81e75..9988f59f1a 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C @@ -104,13 +104,25 @@ Foam::wedgeFaPatchField::wedgeFaPatchField template Foam::tmp> Foam::wedgeFaPatchField::snGrad() const { - const Field pif (this->patchInternalField()); + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type: treat like zero-gradient + return tmp>::New(this->size(), Foam::zero{}); + } + else + { + const auto& rot = refCast(this->patch()).faceT(); - return - ( - transform(refCast(this->patch()).faceT(), pif) - - pif - )*(0.5*this->patch().deltaCoeffs()); + const Field pif(this->patchInternalField()); + + const auto& dc = this->patch().deltaCoeffs(); + + return + ( + (0.5*dc) + * (transform(rot, pif) - pif) + ); + } } @@ -122,14 +134,20 @@ void Foam::wedgeFaPatchField::evaluate(const Pstream::commsTypes) this->updateCoeffs(); } - faPatchField::operator== - ( - transform + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type: treat like zero-gradient + this->extrapolateInternal(); + } + else + { + const auto& rot = refCast(this->patch()).edgeT(); + + faPatchField::operator== ( - refCast(this->patch()).edgeT(), - this->patchInternalField() - ) - ); + transform(rot, this->patchInternalField()) + ); + } } diff --git a/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.H b/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.H index 22858d7db5..a1e33ce9a0 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.H @@ -133,18 +133,6 @@ public: }; -// * * * * * * * * * * * Template Specialisations * * * * * * * * * * * * * // - -template<> -tmp wedgeFaPatchField::snGrad() const; - -template<> -void wedgeFaPatchField::evaluate -( - const Pstream::commsTypes commsType -); - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchFields.C b/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchFields.C index 15a0ff125f..c38c3bac35 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchFields.C +++ b/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchFields.C @@ -36,26 +36,4 @@ namespace Foam makeFaPatchFields(wedge); } -// * * * * * * * * * * * * * * * Specialisations * * * * * * * * * * * * * * // - -template<> -Foam::tmp -Foam::wedgeFaPatchField::snGrad() const -{ - return tmp::New(size(), Zero); -} - - -template<> -void Foam::wedgeFaPatchField::evaluate(const Pstream::commsTypes) -{ - if (!updated()) - { - updateCoeffs(); - } - - this->operator==(patchInternalField()); -} - - // ************************************************************************* // diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index b0cb2bc25b..8a149485ce 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -128,7 +128,6 @@ $(fvPatchFields)/fvPatchField/fvPatchFieldBase.C $(fvPatchFields)/fvPatchField/fvPatchFields.C basicFvPatchFields = $(fvPatchFields)/basic -$(basicFvPatchFields)/basicSymmetry/basicSymmetryFvPatchFields.C $(basicFvPatchFields)/calculated/calculatedFvPatchFields.C $(basicFvPatchFields)/extrapolatedCalculated/extrapolatedCalculatedFvPatchFields.C $(basicFvPatchFields)/coupled/coupledFvPatchFields.C diff --git a/src/finiteVolume/fields/fvPatchFields/basic/basicSymmetry/basicSymmetryFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/basicSymmetry/basicSymmetryFvPatchField.C index 5d45a94aea..a4054b2b82 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/basicSymmetry/basicSymmetryFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/basicSymmetry/basicSymmetryFvPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -85,13 +86,25 @@ template Foam::tmp> Foam::basicSymmetryFvPatchField::snGrad() const { - tmp nHat = this->patch().nf(); + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type : treat like zero-gradient + return tmp>::New(this->size(), Foam::zero{}); + } + else + { + tmp nHat = this->patch().nf(); - const Field iF(this->patchInternalField()); + const auto& dc = this->patch().deltaCoeffs(); - return - (transform(I - 2.0*sqr(nHat), iF) - iF) - *(this->patch().deltaCoeffs()/2.0); + const Field pif(this->patchInternalField()); + + return + ( + (0.5*dc) + * (transform(I - 2.0*sqr(nHat), pif) - pif) + ); + } } @@ -103,14 +116,22 @@ void Foam::basicSymmetryFvPatchField::evaluate(const Pstream::commsTypes) this->updateCoeffs(); } - tmp nHat = this->patch().nf(); + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type : treat like zero-gradient + this->extrapolateInternal(); + } + else + { + tmp nHat = this->patch().nf(); - const Field iF(this->patchInternalField()); + const Field pif(this->patchInternalField()); - Field::operator= - ( - (iF + transform(I - 2.0*sqr(nHat), iF))/2.0 - ); + Field::operator= + ( + 0.5*(pif + transform(I - 2.0*sqr(nHat), pif)) + ); + } transformFvPatchField::evaluate(); } diff --git a/src/finiteVolume/fields/fvPatchFields/basic/basicSymmetry/basicSymmetryFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/basic/basicSymmetry/basicSymmetryFvPatchField.H index 3135c1662c..0345dfd663 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/basicSymmetry/basicSymmetryFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/basic/basicSymmetry/basicSymmetryFvPatchField.H @@ -139,18 +139,6 @@ public: }; -// * * * * * * * * * * * Template Specialisations * * * * * * * * * * * * * // - -template<> -tmp basicSymmetryFvPatchField::snGrad() const; - -template<> -void basicSymmetryFvPatchField::evaluate -( - const Pstream::commsTypes commsType -); - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/finiteVolume/fields/fvPatchFields/basic/basicSymmetry/basicSymmetryFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/basic/basicSymmetry/basicSymmetryFvPatchFields.C deleted file mode 100644 index 484a7354f5..0000000000 --- a/src/finiteVolume/fields/fvPatchFields/basic/basicSymmetry/basicSymmetryFvPatchFields.C +++ /dev/null @@ -1,59 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2013 OpenFOAM Foundation -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "basicSymmetryFvPatchField.H" -#include "volFields.H" - -// No run-time selection - -// * * * * * * * * * * * * * * * Specialisations * * * * * * * * * * * * * * // - -template<> -Foam::tmp -Foam::basicSymmetryFvPatchField::snGrad() const -{ - return tmp::New(size(), Zero); -} - - -template<> -void Foam::basicSymmetryFvPatchField::evaluate -( - const Pstream::commsTypes -) -{ - if (!updated()) - { - updateCoeffs(); - } - - scalarField::operator=(patchInternalField()); - transformFvPatchField::evaluate(); -} - - -// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchField.H index 9211155c71..25f6434158 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchField.H @@ -157,18 +157,6 @@ public: }; -// * * * * * * * * * * * Template Specialisations * * * * * * * * * * * * * // - -template<> -tmp transformFvPatchField::valueInternalCoeffs -( - const tmp& -) const; - -template<> -tmp transformFvPatchField::gradientInternalCoeffs() const; - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchFields.C index ffb781a7f1..2f88c5f87f 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchFields.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchFields.C @@ -37,25 +37,4 @@ namespace Foam } -// * * * * * * * * * * * * * * * Specialisations * * * * * * * * * * * * * * // - -template<> -Foam::tmp -Foam::transformFvPatchField::valueInternalCoeffs -( - const tmp& -) const -{ - return tmp::New(size(), 1.0); -} - - -template<> -Foam::tmp -Foam::transformFvPatchField::gradientInternalCoeffs() const -{ - return tmp::New(size(), Zero); -} - - // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.C index 4a9705bada..485cd67afd 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation + Copyright (C) 2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,7 +28,6 @@ License #include "symmetryPlaneFvPatchField.H" - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template @@ -120,13 +120,25 @@ template Foam::tmp> Foam::symmetryPlaneFvPatchField::snGrad() const { - vector nHat(symmetryPlanePatch_.n()); + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type: treat like zero-gradient + return tmp>::New(this->size(), Foam::zero{}); + } + else + { + const symmTensor rot(I - 2.0*sqr(symmetryPlanePatch_.n())); - const Field iF(this->patchInternalField()); + const Field pif(this->patchInternalField()); - return - (transform(I - 2.0*sqr(nHat), iF) - iF) - *(this->patch().deltaCoeffs()/2.0); + const auto& dc = this->patch().deltaCoeffs(); + + return + ( + (0.5*dc) + * (transform(rot, pif) - pif) + ); + } } @@ -138,14 +150,19 @@ void Foam::symmetryPlaneFvPatchField::evaluate(const Pstream::commsTypes) this->updateCoeffs(); } - vector nHat(symmetryPlanePatch_.n()); + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type: treat like zero-gradient + this->extrapolateInternal(); + } + else + { + const symmTensor rot(I - 2.0*sqr(symmetryPlanePatch_.n())); - const Field iF(this->patchInternalField()); + const Field pif(this->patchInternalField()); - Field::operator= - ( - (iF + transform(I - 2.0*sqr(nHat), iF))/2.0 - ); + Field::operator=(0.5*(pif + transform(rot, pif))); + } transformFvPatchField::evaluate(); } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.H index 5ea077b08a..ff9bb1c315 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.H @@ -49,8 +49,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef symmetryPlaneFvPatchField_H -#define symmetryPlaneFvPatchField_H +#ifndef Foam_symmetryPlaneFvPatchField_H +#define Foam_symmetryPlaneFvPatchField_H #include "basicSymmetryFvPatchField.H" #include "symmetryPlaneFvPatch.H" @@ -61,7 +61,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class symmetryPlaneFvPatchField Declaration + Class symmetryPlaneFvPatchField Declaration \*---------------------------------------------------------------------------*/ template @@ -153,18 +153,6 @@ public: }; -// * * * * * * * * * * * Template Specialisations * * * * * * * * * * * * * // - -template<> -tmp symmetryPlaneFvPatchField::snGrad() const; - -template<> -void symmetryPlaneFvPatchField::evaluate -( - const Pstream::commsTypes commsType -); - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchFields.C index e3ed414075..b8ee6a9fd8 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchFields.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchFields.C @@ -37,30 +37,4 @@ namespace Foam } -// * * * * * * * * * * * * * * * Specialisations * * * * * * * * * * * * * * // - -template<> -Foam::tmp -Foam::symmetryPlaneFvPatchField::snGrad() const -{ - return tmp::New(size(), Zero); -} - - -template<> -void Foam::symmetryPlaneFvPatchField::evaluate -( - const Pstream::commsTypes -) -{ - if (!updated()) - { - updateCoeffs(); - } - - scalarField::operator=(patchInternalField()); - transformFvPatchField::evaluate(); -} - - // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C index c8094daa0c..3508eff784 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2024 OpenCFD Ltd. + Copyright (C) 2024-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -119,12 +119,25 @@ Foam::wedgeFvPatchField::wedgeFvPatchField template Foam::tmp> Foam::wedgeFvPatchField::snGrad() const { - const Field pif(this->patchInternalField()); + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type : treat like zero-gradient + return tmp>::New(this->size(), Foam::zero{}); + } + else + { + const auto& rot = refCast(this->patch()).cellT(); - return - ( - transform(refCast(this->patch()).cellT(), pif) - pif - )*(0.5*this->patch().deltaCoeffs()); + const Field pif(this->patchInternalField()); + + const auto& dc = this->patch().deltaCoeffs(); + + return + ( + (0.5*dc) + * (transform(rot, pif) - pif) + ); + } } @@ -136,14 +149,20 @@ void Foam::wedgeFvPatchField::evaluate(const Pstream::commsTypes) this->updateCoeffs(); } - fvPatchField::operator== - ( - transform + if constexpr (!is_rotational_vectorspace_v) + { + // Rotational-invariant type : treat like zero-gradient + this->extrapolateInternal(); + } + else + { + const auto& rot = refCast(this->patch()).faceT(); + + fvPatchField::operator== ( - refCast(this->patch()).faceT(), - this->patchInternalField() - ) - ); + transform(rot, this->patchInternalField()) + ); + } } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.H index fe9e31f644..df71293c5f 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.H @@ -138,7 +138,7 @@ public: } - // Member functions + // Member Functions //- Return gradient at boundary virtual tmp> snGrad() const; @@ -154,18 +154,6 @@ public: }; -// * * * * * * * * * * * Template Specialisations * * * * * * * * * * * * * // - -template<> -tmp wedgeFvPatchField::snGrad() const; - -template<> -void wedgeFvPatchField::evaluate -( - const Pstream::commsTypes commsType -); - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchFields.C index 7225ce6108..4bdc35186e 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchFields.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchFields.C @@ -37,29 +37,4 @@ namespace Foam } -// * * * * * * * * * * * * * * * Specialisations * * * * * * * * * * * * * * // - -template<> -Foam::tmp -Foam::wedgeFvPatchField::snGrad() const -{ - return tmp::New(size(), Zero); -} - - -template<> -void Foam::wedgeFvPatchField::evaluate -( - const Pstream::commsTypes -) -{ - if (!updated()) - { - updateCoeffs(); - } - - this->operator==(patchInternalField()); -} - - // ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/wedge/wedgeFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/wedge/wedgeFvPatch.C index c039bdca83..c6d39a8121 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/wedge/wedgeFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/wedge/wedgeFvPatch.C @@ -33,23 +33,23 @@ License namespace Foam { -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - defineTypeNameAndDebug(wedgeFvPatch, 0); addToRunTimeSelectionTable(fvPatch, wedgeFvPatch, polyPatch); +} // End namespace Foam + // * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * // -wedgeFvPatch::wedgeFvPatch(const polyPatch& patch, const fvBoundaryMesh& bm) +Foam::wedgeFvPatch::wedgeFvPatch +( + const polyPatch& patch, + const fvBoundaryMesh& bm +) : fvPatch(patch, bm), wedgePolyPatch_(refCast(patch)) {} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/wedge/wedgeFvPatch.H b/src/finiteVolume/fvMesh/fvPatches/constraint/wedge/wedgeFvPatch.H index 913f6c1c51..ce188fe474 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/wedge/wedgeFvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/wedge/wedgeFvPatch.H @@ -34,8 +34,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef wedgeFvPatch_H -#define wedgeFvPatch_H +#ifndef Foam_wedgeFvPatch_H +#define Foam_wedgeFvPatch_H #include "fvPatch.H" #include "wedgePolyPatch.H" @@ -53,7 +53,7 @@ class wedgeFvPatch : public fvPatch { - // Private data + // Private Data const wedgePolyPatch& wedgePolyPatch_; @@ -70,21 +70,21 @@ public: wedgeFvPatch(const polyPatch& patch, const fvBoundaryMesh& bm); - // Member functions + // Member Functions - // Access + // Access - //- Return face transformation tensor - const tensor& faceT() const - { - return wedgePolyPatch_.faceT(); - } + //- Return face transformation tensor + const tensor& faceT() const noexcept + { + return wedgePolyPatch_.faceT(); + } - //- Return neighbour-cell transformation tensor - const tensor& cellT() const - { - return wedgePolyPatch_.cellT(); - } + //- Return neighbour-cell transformation tensor + const tensor& cellT() const noexcept + { + return wedgePolyPatch_.cellT(); + } }; diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWaveAddressing/meshWaveAddressingPatchDistMethod.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWaveAddressing/meshWaveAddressingPatchDistMethod.C index 8ffaac012c..c68d5b2bf0 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWaveAddressing/meshWaveAddressingPatchDistMethod.C +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWaveAddressing/meshWaveAddressingPatchDistMethod.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2023 OpenCFD Ltd. + Copyright (C) 2023-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -88,12 +88,14 @@ bool Foam::patchDistMethods::meshWaveAddressing::correct // since the supplied options (wall patchIDs and correctWalls) // are not assumed to be different from the defaults of other usage. + const labelList patchIds(patchIDs_.sortedToc()); + // Calculate distance and addressing const auto& wDist = wallDistAddressing::New ( "wall", mesh_, - patchIDs_.sortedToc(), + patchIds, correctWalls_ ); @@ -102,31 +104,18 @@ bool Foam::patchDistMethods::meshWaveAddressing::correct // Note: copying value only so might not be consistent with supplied // patch types (e.g. zeroGradient when called from wallDist). Assume // only affected ones are the supplied patches ... - { - auto& bfld = y.boundaryFieldRef(); - const label startOfRequests = UPstream::nRequests(); - for (const label patchi : patchIDs_) - { - bfld[patchi].initEvaluate(UPstream::commsTypes::nonBlocking); - } - // Wait for outstanding requests - UPstream::waitRequests(startOfRequests); - - for (const label patchi : patchIDs_) - { - bfld[patchi].evaluate(UPstream::commsTypes::nonBlocking); - } - } + y.boundaryFieldRef().evaluateSelected(patchIds); // Only calculate n if the field is defined if (notNull(n)) { - for (const label patchi : patchIDs_) + auto& bfld = n.boundaryFieldRef(); + + for (const label patchi : patchIds) { - auto& pnf = n.boundaryFieldRef()[patchi]; - pnf == pnf.patch().nf(); + bfld[patchi] == bfld[patchi].patch().nf(); } // No problem with inconsistency as for y (see above) since doing diff --git a/src/functionObjects/field/cellDecomposer/cellDecomposerTemplates.C b/src/functionObjects/field/cellDecomposer/cellDecomposerTemplates.C index 765559fc29..f99bc2817e 100644 --- a/src/functionObjects/field/cellDecomposer/cellDecomposerTemplates.C +++ b/src/functionObjects/field/cellDecomposer/cellDecomposerTemplates.C @@ -39,79 +39,17 @@ License // GeometricField& fld //) const //{ -// auto& fldBf = fld.boundaryFieldRef(); -// -// const UPstream::commsTypes commsType = UPstream::defaultCommsType; -// const label startOfRequests = UPstream::nRequests(); -// -// if +// fld.boundaryFieldRef().evaluate_if // ( -// commsType == UPstream::commsTypes::blocking -// || commsType == UPstream::commsTypes::nonBlocking -// ) -// { -// forAll(fldBf, patchi) +// [](const auto& pfld) -> bool // { -// fvPatchField& tgtField = fldBf[patchi]; -// -// if +// return // ( -// tgtField.type() == tgtField.patch().patch().type() -// && polyPatch::constraintType(tgtField.patch().patch().type()) -// ) -// { -// tgtField.initEvaluate(commsType); -// } +// pfld.type() == pfld.patch().patch().type() +// && polyPatch::constraintType(pfld.patch().patch().type()) +// ); // } -// -// // Wait for outstanding requests -// if (commsType == UPstream::commsTypes::nonBlocking) -// { -// UPstream::waitRequests(startOfRequests); -// } -// -// forAll(fldBf, patchi) -// { -// fvPatchField& tgtField = fldBf[patchi]; -// -// if -// ( -// tgtField.type() == tgtField.patch().patch().type() -// && polyPatch::constraintType(tgtField.patch().patch().type()) -// ) -// { -// tgtField.evaluate(commsType); -// } -// } -// } -// else if (commsType == UPstream::commsTypes::scheduled) -// { -// const lduSchedule& patchSchedule = -// fld.mesh().globalData().patchSchedule(); -// -// for (const auto& schedEval : patchSchedule) -// { -// const label patchi = schedEval.patch; -// -// fvPatchField& tgtField = fldBf[patchi]; -// -// if -// ( -// tgtField.type() == tgtField.patch().patch().type() -// && polyPatch::constraintType(tgtField.patch().patch().type()) -// ) -// { -// if (schedEval.init) -// { -// tgtField.initEvaluate(commsType); -// } -// else -// { -// tgtField.evaluate(commsType); -// } -// } -// } -// } +// ); //} template diff --git a/src/functionObjects/field/mapFields/mapFieldsTemplates.C b/src/functionObjects/field/mapFields/mapFieldsTemplates.C index 40536b9dba..741cbdc04a 100644 --- a/src/functionObjects/field/mapFields/mapFieldsTemplates.C +++ b/src/functionObjects/field/mapFields/mapFieldsTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2022 OpenCFD Ltd. + Copyright (C) 2016-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,72 +36,18 @@ void Foam::functionObjects::mapFields::evaluateConstraintTypes GeometricField& fld ) const { - auto& bfld = fld.boundaryFieldRef(); - - const UPstream::commsTypes commsType = UPstream::defaultCommsType; - - if + fld.boundaryFieldRef().evaluate_if ( - commsType == UPstream::commsTypes::buffered - || commsType == UPstream::commsTypes::nonBlocking - ) - { - const label startOfRequests = UPstream::nRequests(); - - for (auto& pfld : bfld) + [](const auto& pfld) -> bool { - if + return ( pfld.type() == pfld.patch().patch().type() && polyPatch::constraintType(pfld.patch().patch().type()) - ) - { - pfld.initEvaluate(commsType); - } - } - - // Wait for outstanding requests (non-blocking) - UPstream::waitRequests(startOfRequests); - - for (auto& pfld : bfld) - { - if - ( - pfld.type() == pfld.patch().patch().type() - && polyPatch::constraintType(pfld.patch().patch().type()) - ) - { - pfld.evaluate(commsType); - } - } - } - else if (commsType == UPstream::commsTypes::scheduled) - { - const lduSchedule& patchSchedule = - fld.mesh().globalData().patchSchedule(); - - for (const auto& schedEval : patchSchedule) - { - const label patchi = schedEval.patch; - auto& pfld = bfld[patchi]; - - if - ( - pfld.type() == pfld.patch().patch().type() - && polyPatch::constraintType(pfld.patch().patch().type()) - ) - { - if (schedEval.init) - { - pfld.initEvaluate(commsType); - } - else - { - pfld.evaluate(commsType); - } - } - } - } + ); + }, + UPstream::defaultCommsType + ); } diff --git a/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C b/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C index a93838a462..50c2e6e359 100644 --- a/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C +++ b/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2023 OpenCFD Ltd. + Copyright (C) 2018-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -182,31 +182,16 @@ void Foam::cellCellStencil::correctBoundaryConditions GeoField& psi ) { - // Version of GeoField::correctBoundaryConditions that exclude evaluation - // of oversetFvPatchFields + // correctBoundaryConditions excluding oversetFvPatchFields - auto& bfld = psi.boundaryFieldRef(); - - const label startOfRequests = UPstream::nRequests(); - - for (auto& pfld : bfld) - { - if (!isA(pfld)) + psi.boundaryFieldRef().evaluate_if + ( + [](const auto& pfld) { - pfld.initEvaluate(UPstream::commsTypes::nonBlocking); - } - } - - // Wait for outstanding requests (non-blocking) - UPstream::waitRequests(startOfRequests); - - for (auto& pfld : bfld) - { - if (!isA(pfld)) - { - pfld.evaluate(UPstream::commsTypes::nonBlocking); - } - } + return (!isA(pfld)); + }, + UPstream::commsTypes::nonBlocking + ); } diff --git a/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C b/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C index 892e2f652f..71614d2e06 100644 --- a/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C +++ b/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C @@ -1033,8 +1033,9 @@ bool Foam::cellCellStencils::cellVolumeWeight::update() oversetFvMeshBase::correctBoundaryConditions < volScalarField, - oversetFvPatchField - >(cellInterpolationWeight_.boundaryFieldRef(), false); + oversetFvPatchField, + false + >(cellInterpolationWeight_.boundaryFieldRef()); DynamicList