diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C index 69ae3130c7..f2f775ccc4 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C @@ -122,7 +122,7 @@ Foam::tmp> Foam::pointPatchField::patchInternalField ( const Field& iF, - const labelList& meshPoints + const labelUList& meshPoints ) const { // Check size @@ -194,7 +194,7 @@ void Foam::pointPatchField::addToInternalField ( Field& iF, const Field& pF, - const labelList& points + const labelUList& points ) const { // Check size @@ -233,7 +233,7 @@ void Foam::pointPatchField::setInInternalField ( Field& iF, const Field& pF, - const labelList& meshPoints + const labelUList& meshPoints ) const { // Check size @@ -310,8 +310,4 @@ Foam::Ostream& Foam::operator<< } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "pointPatchFieldNew.C" - // ************************************************************************* // diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H index 8ea1f2f63f..32e1ad2d7e 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H @@ -390,24 +390,27 @@ public: return patch().size(); } - //- Return dimensioned internal field reference + //- Return const-reference to the dimensioned internal field const DimensionedField& internalField() const noexcept { return internalField_; } - //- Return internal field reference + //- Return const-reference to the internal field values const Field& primitiveField() const noexcept { return internalField_; } + + // Evaluation Functions + //- Return field created from appropriate internal field values tmp> patchInternalField() const; //- Return field created from appropriate internal field values - // given internal field reference + //- given internal field reference template tmp> patchInternalField ( @@ -415,16 +418,16 @@ public: ) const; //- Return field created from selected internal field values - // given internal field reference + //- given internal field reference template tmp> patchInternalField ( const Field& iF, - const labelList& meshPoints + const labelUList& meshPoints ) const; //- Given the internal field and a patch field, - // add the patch field to the internal field + //- add the patch field to the internal field template void addToInternalField ( @@ -433,27 +436,27 @@ public: ) const; //- Given the internal field and a patch field, - // add selected elements of the patch field to the internal field + //- add selected elements of the patch field to the internal field template void addToInternalField ( Field& iF, const Field& pF, - const labelList& points + const labelUList& points ) const; //- Given the internal field and a patch field, - // set the patch field in the internal field + //- set the patch field in the internal field template void setInInternalField ( Field& iF, const Field& pF, - const labelList& meshPoints + const labelUList& meshPoints ) const; //- Given the internal field and a patch field, - // set the patch field in the internal field + //- set the patch field in the internal field template void setInInternalField ( @@ -581,6 +584,7 @@ const pointPatchField& operator+ #ifdef NoRepository #include "pointPatchField.C" + #include "pointPatchFieldNew.C" #include "calculatedPointPatchField.H" #include "zeroGradientPointPatchField.H" #endif diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldBase.C b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldBase.C index 3ecd9e583c..3c6db48140 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldBase.C +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldBase.C @@ -105,7 +105,7 @@ void Foam::pointPatchFieldBase::readDict(const dictionary& dict) const Foam::objectRegistry& Foam::pointPatchFieldBase::db() const { - return patch_.boundaryMesh().mesh()(); + return patch_.boundaryMesh().mesh().thisDb(); } diff --git a/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C b/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C index 7f7ea57cd7..6c6ff54bb0 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C +++ b/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,7 +67,7 @@ Foam::labelList Foam::pointBoundaryMesh::indices const bool useGroups ) const { - return mesh()().boundaryMesh().indices(matcher, useGroups); + return mesh().boundaryMesh().indices(matcher, useGroups); } @@ -77,13 +77,13 @@ Foam::labelList Foam::pointBoundaryMesh::indices const bool useGroups ) const { - return mesh()().boundaryMesh().indices(matcher, useGroups); + return mesh().boundaryMesh().indices(matcher, useGroups); } Foam::label Foam::pointBoundaryMesh::findPatchID(const word& patchName) const { - return mesh()().boundaryMesh().findPatchID(patchName); + return mesh().boundaryMesh().findPatchID(patchName); } diff --git a/src/OpenFOAM/meshes/pointMesh/pointMesh.H b/src/OpenFOAM/meshes/pointMesh/pointMesh.H index 16e9b92319..ea960a5485 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointMesh.H +++ b/src/OpenFOAM/meshes/pointMesh/pointMesh.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2013 OpenFOAM Foundation - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -112,7 +112,7 @@ public: } //- Return reference to boundary mesh - const pointBoundaryMesh& boundary() const + const pointBoundaryMesh& boundary() const noexcept { return boundary_; } @@ -136,7 +136,16 @@ public: } - // Mesh motion + // Volume Mesh + + //- Return boundary mesh for underlying volume mesh + const polyBoundaryMesh& boundaryMesh() const + { + return GeoMesh::mesh_.boundaryMesh(); + } + + + // Mesh Motion //- Move points bool movePoints(); diff --git a/src/finiteArea/faMesh/faPatches/constraint/cyclic/cyclicFaPatch.C b/src/finiteArea/faMesh/faPatches/constraint/cyclic/cyclicFaPatch.C index cb3612260f..d1ebed1da7 100644 --- a/src/finiteArea/faMesh/faPatches/constraint/cyclic/cyclicFaPatch.C +++ b/src/finiteArea/faMesh/faPatches/constraint/cyclic/cyclicFaPatch.C @@ -321,7 +321,9 @@ Foam::tmp Foam::cyclicFaPatch::interfaceInternalField const labelUList& edgeFaces ) const { - return patchInternalField(internalData, edgeFaces); + auto tpfld = tmp::New(); + patchInternalField(internalData, edgeFaces, tpfld.ref()); + return tpfld; } diff --git a/src/finiteArea/faMesh/faPatches/constraint/processor/processorFaPatch.C b/src/finiteArea/faMesh/faPatches/constraint/processor/processorFaPatch.C index 2b3a1a5df9..3312cb8173 100644 --- a/src/finiteArea/faMesh/faPatches/constraint/processor/processorFaPatch.C +++ b/src/finiteArea/faMesh/faPatches/constraint/processor/processorFaPatch.C @@ -492,7 +492,9 @@ Foam::tmp Foam::processorFaPatch::interfaceInternalField const labelUList& edgeFaces ) const { - return patchInternalField(internalData, edgeFaces); + auto tpfld = tmp::New(); + patchInternalField(internalData, edgeFaces, tpfld.ref()); + return tpfld; } diff --git a/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H b/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H index 7c2cecc140..625b940cce 100644 --- a/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H +++ b/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2020-2022 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -421,32 +421,42 @@ public: // Evaluation - //- Extract internal field next to patch using edgeFaces mapping + //- Extract internal field next to patch using specified addressing + // \param internalData The internal field to extract from + // \param addressing Addressing from patch into internal field + // \param [out] pfld The extracted patch field. + // It is always resized according to the patch size(), + // which can be smaller than the addressing size template inline void patchInternalField ( - const UList& f, - const labelUList& edgeFaces, + const UList& internalData, + const labelUList& addressing, + Field& pfld + ) const; + + //- Extract internal field next to patch as patch field + //- using edgeFaces() mapping. + // \param internalData The internal field to extract from + // \param [out] pfld The extracted patch field. + // It is always resized according to the patch size(), + // which can be smaller than the edgeFaces() size + template + void patchInternalField + ( + const UList& internalData, Field& pfld ) const; //- Return given internal field next to patch as patch field + //- using edgeFaces() mapping. + // \param internalData The internal field to extract from template - tmp> patchInternalField(const UList&) const; - - //- Return given internal field next to patch as patch field - //- using provided addressing - template - tmp> patchInternalField + tmp> patchInternalField ( - const UList& f, - const labelUList& edgeFaces + const UList& internalData ) const; - //- Extract internal field next to patch as patch field - template - void patchInternalField(const UList&, Field&) const; - //- Return the patch field of the GeometricField //- corresponding to this patch. template diff --git a/src/finiteArea/faMesh/faPatches/faPatch/faPatchTemplates.C b/src/finiteArea/faMesh/faPatches/faPatch/faPatchTemplates.C index f4550c216a..892e54280c 100644 --- a/src/finiteArea/faMesh/faPatches/faPatch/faPatchTemplates.C +++ b/src/finiteArea/faMesh/faPatches/faPatch/faPatchTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2019-2022 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,53 +33,42 @@ License template void Foam::faPatch::patchInternalField ( - const UList& f, - const labelUList& edgeFaces, + const UList& internalData, + const labelUList& addressing, Field& pfld ) const { - pfld.resize(size()); + const label len = this->size(); - forAll(pfld, i) + pfld.resize_nocopy(len); + + for (label i = 0; i < len; ++i) { - pfld[i] = f[edgeFaces[i]]; + pfld[i] = internalData[addressing[i]]; } } -template -Foam::tmp> Foam::faPatch::patchInternalField -( - const UList& f -) const -{ - auto tpfld = tmp>::New(size()); - patchInternalField(f, this->edgeFaces(), tpfld.ref()); - return tpfld; -} - - -template -Foam::tmp> Foam::faPatch::patchInternalField -( - const UList& f, - const labelUList& edgeFaces -) const -{ - auto tpfld = tmp>::New(size()); - patchInternalField(f, edgeFaces, tpfld.ref()); - return tpfld; -} - - template void Foam::faPatch::patchInternalField ( - const UList& f, + const UList& internalData, Field& pfld ) const { - patchInternalField(f, this->edgeFaces(), pfld); + patchInternalField(internalData, this->edgeFaces(), pfld); +} + + +template +Foam::tmp> Foam::faPatch::patchInternalField +( + const UList& internalData +) const +{ + auto tpfld = tmp>::New(); + patchInternalField(internalData, this->edgeFaces(), tpfld.ref()); + return tpfld; } diff --git a/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.C b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.C index d4f257b80e..d1d340b8d9 100644 --- a/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.C @@ -128,18 +128,17 @@ void clampedPlateFaPatchField::evaluate(const Pstream::commsTypes) template -tmp > clampedPlateFaPatchField::valueInternalCoeffs +tmp> clampedPlateFaPatchField::valueInternalCoeffs ( const tmp& ) const { - return tmp> - (new Field(this->size(), pTraits::zero)); + return tmp>::New(this->size(), Zero); } template -tmp > clampedPlateFaPatchField::valueBoundaryCoeffs +tmp> clampedPlateFaPatchField::valueBoundaryCoeffs ( const tmp& ) const @@ -149,7 +148,7 @@ tmp > clampedPlateFaPatchField::valueBoundaryCoeffs template -tmp > +tmp> clampedPlateFaPatchField::gradientInternalCoeffs() const { return -Type(pTraits::one)*this->patch().deltaCoeffs(); @@ -157,7 +156,7 @@ clampedPlateFaPatchField::gradientInternalCoeffs() const template -tmp > +tmp> clampedPlateFaPatchField::gradientBoundaryCoeffs() const { return this->patch().deltaCoeffs()*(*this); diff --git a/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H index 4178ffb782..ad740c900b 100644 --- a/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H @@ -131,12 +131,12 @@ public: ); //- Construct and return a clone setting internal field reference - virtual tmp > clone + virtual tmp> clone ( const DimensionedField& iF ) const { - return tmp > + return tmp> ( new clampedPlateFaPatchField(*this, iF) ); @@ -169,25 +169,25 @@ public: //- Return the matrix diagonal coefficients corresponding to the //- evaluation of the value of this patchField with given weights - virtual tmp > valueInternalCoeffs + virtual tmp> valueInternalCoeffs ( const tmp& ) const; //- Return the matrix source coefficients corresponding to the //- evaluation of the value of this patchField with given weights - virtual tmp > valueBoundaryCoeffs + virtual tmp> valueBoundaryCoeffs ( const tmp& ) const; //- Return the matrix diagonal coefficients corresponding to the //- evaluation of the gradient of this patchField - virtual tmp > gradientInternalCoeffs() const; + virtual tmp> gradientInternalCoeffs() const; //- Return the matrix source coefficients corresponding to the //- evaluation of the gradient of this patchField - virtual tmp > gradientBoundaryCoeffs() const; + virtual tmp> gradientBoundaryCoeffs() const; // IO diff --git a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.C b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.C index 60f7368ed8..ff5fc8f317 100644 --- a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.C +++ b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.C @@ -128,14 +128,6 @@ Foam::faPatchField::faPatchField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -const Foam::objectRegistry& Foam::faPatchField::db() const -{ - // Note: Lookup fields from the field DB rather than the mesh - return internalField_.db(); -} - - template void Foam::faPatchField::check(const faPatchField& rhs) const { @@ -158,6 +150,13 @@ Foam::faPatchField::patchInternalField() const } +template +void Foam::faPatchField::patchInternalField(Field& pfld) const +{ + patch().patchInternalField(internalField_, pfld); +} + + template void Foam::faPatchField::autoMap(const faPatchFieldMapper& m) { @@ -407,8 +406,4 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const faPatchField& ptf) } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "faPatchFieldNew.C" - // ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H index de98d4ebef..bc915135c5 100644 --- a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H +++ b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H @@ -143,7 +143,7 @@ public: // Access //- The associated objectRegistry - /// const objectRegistry& db() const; + const objectRegistry& db() const; //- Return the patch const faPatch& patch() const noexcept @@ -394,17 +394,14 @@ public: // Access - //- Return local objectRegistry - const objectRegistry& db() const; - - //- Return dimensioned internal field reference - const DimensionedField& - internalField() const noexcept + //- Return const-reference to the dimensioned internal field + const DimensionedField& internalField() + const noexcept { return internalField_; } - //- Return internal field reference + //- Return const-reference to the internal field values const Field& primitiveField() const noexcept { return internalField_; @@ -432,9 +429,13 @@ public: //- Return patch-normal gradient virtual tmp> snGrad() const; - //- Return internal field next to patch as patch field + //- Return internal field next to patch virtual tmp> patchInternalField() const; + //- Extract internal field next to patch + // \param [out] pfld The extracted patch field. + virtual void patchInternalField(Field& pfld) const; + //- Return patchField on the opposite patch of a coupled patch virtual tmp> patchNeighbourField() const { @@ -556,6 +557,7 @@ public: #ifdef NoRepository #include "faPatchField.C" + #include "faPatchFieldNew.C" #include "calculatedFaPatchField.H" #include "zeroGradientFaPatchField.H" #endif diff --git a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchFieldBase.C b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchFieldBase.C index 8edc4781b2..eb99171134 100644 --- a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchFieldBase.C +++ b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchFieldBase.C @@ -26,6 +26,8 @@ License \*---------------------------------------------------------------------------*/ #include "faPatchField.H" +#include "faBoundaryMesh.H" +#include "faMesh.H" #include "dictionary.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -103,10 +105,10 @@ void Foam::faPatchFieldBase::readDict(const dictionary& dict) } -// const Foam::objectRegistry& Foam::faPatchFieldBase::db() const -// { -// return patch_.boundaryMesh().mesh().thisDb(); -// } +const Foam::objectRegistry& Foam::faPatchFieldBase::db() const +{ + return patch_.boundaryMesh().mesh().thisDb(); +} void Foam::faPatchFieldBase::checkPatch(const faPatchFieldBase& rhs) const diff --git a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.C b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.C index c9c93d5af2..d45518577a 100644 --- a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.C +++ b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.C @@ -125,14 +125,6 @@ Foam::faePatchField::faePatchField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -const Foam::objectRegistry& Foam::faePatchField::db() const -{ - // Note: Lookup fields from the field DB rather than the mesh - return internalField_.db(); -} - - template void Foam::faePatchField::check(const faePatchField& rhs) const { @@ -373,8 +365,4 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const faePatchField& ptf) } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "faePatchFieldNew.C" - // ************************************************************************* // diff --git a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H index 950f9d5de1..720a4f00e5 100644 --- a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H +++ b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H @@ -128,7 +128,7 @@ public: // Access //- The associated objectRegistry - /// const objectRegistry& db() const; + const objectRegistry& db() const; //- Return the patch const faPatch& patch() const noexcept @@ -358,17 +358,14 @@ public: // Access - //- Return local objectRegistry - const objectRegistry& db() const; - - //- Return dimensioned internal field reference + //- Return const-reference to the dimensioned internal field const DimensionedField& internalField() const noexcept { return internalField_; } - //- Return internal field reference + //- Return const-reference to the internal field values const Field& primitiveField() const noexcept { return internalField_; @@ -445,6 +442,7 @@ public: #ifdef NoRepository #include "faePatchField.C" + #include "faePatchFieldNew.C" #include "calculatedFaePatchField.H" #endif diff --git a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchFieldBase.C b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchFieldBase.C index 8dcd03a3ae..0c039570c5 100644 --- a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchFieldBase.C +++ b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchFieldBase.C @@ -26,6 +26,8 @@ License \*---------------------------------------------------------------------------*/ #include "faePatchField.H" +#include "faBoundaryMesh.H" +#include "faMesh.H" #include "dictionary.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -93,10 +95,10 @@ void Foam::faePatchFieldBase::readDict(const dictionary& dict) {} -// const Foam::objectRegistry& Foam::faePatchFieldBase::db() const -// { -// return patch_.boundaryMesh().mesh().thisDb(); -// } +const Foam::objectRegistry& Foam::faePatchFieldBase::db() const +{ + return patch_.boundaryMesh().mesh().thisDb(); +} void Foam::faePatchFieldBase::checkPatch(const faePatchFieldBase& rhs) const diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C index 33d7d5fc30..f2a7c4133f 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C @@ -193,9 +193,9 @@ Foam::fvPatchField::patchInternalField() const template -void Foam::fvPatchField::patchInternalField(Field& pif) const +void Foam::fvPatchField::patchInternalField(Field& pfld) const { - patch().patchInternalField(internalField_, pif); + patch().patchInternalField(internalField_, pfld); } @@ -552,8 +552,4 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const fvPatchField& ptf) } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "fvPatchFieldNew.C" - // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H index 976d9e778d..84d1e333cb 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H @@ -461,14 +461,14 @@ public: // Access - //- Return dimensioned internal field reference + //- Return const-reference to the dimensioned internal field const DimensionedField& internalField() const noexcept { return internalField_; } - //- Return internal field reference + //- Return const-reference to the internal field values const Field& primitiveField() const noexcept { return internalField_; @@ -517,11 +517,12 @@ public: // patches. Sets Updated to true virtual void updateWeightedCoeffs(const scalarField& weights); - //- Return internal field next to patch as patch field + //- Return internal field next to patch virtual tmp> patchInternalField() const; - //- Return internal field next to patch as patch field - virtual void patchInternalField(Field&) const; + //- Extract internal field next to patch + // \param [out] pfld The extracted patch field. + virtual void patchInternalField(Field& pfld) const; //- Return patchField on the opposite patch of a coupled patch virtual tmp> patchNeighbourField() const @@ -684,6 +685,7 @@ public: #ifdef NoRepository #include "fvPatchField.C" + #include "fvPatchFieldNew.C" #include "calculatedFvPatchField.H" #include "zeroGradientFvPatchField.H" #endif diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchFieldBase.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchFieldBase.C index f075ada6ec..1adbf72d62 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchFieldBase.C +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchFieldBase.C @@ -112,7 +112,7 @@ void Foam::fvPatchFieldBase::readDict(const dictionary& dict) const Foam::objectRegistry& Foam::fvPatchFieldBase::db() const { - return patch_.boundaryMesh().mesh(); + return patch_.boundaryMesh().mesh().thisDb(); } diff --git a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C index acb52ae74f..c88be8b532 100644 --- a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C @@ -365,8 +365,4 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const fvsPatchField& ptf) } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "fvsPatchFieldNew.C" - // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H index 1542e9a743..3ee2f1dc26 100644 --- a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H @@ -357,14 +357,14 @@ public: // Access - //- Return dimensioned internal field reference + //- Return const-reference to the dimensioned internal field const DimensionedField& internalField() const noexcept { return internalField_; } - //- Return internal field reference + //- Return const-reference to the internal field values const Field& primitiveField() const noexcept { return internalField_; @@ -441,6 +441,7 @@ public: #ifdef NoRepository #include "fvsPatchField.C" + #include "fvsPatchFieldNew.C" #include "calculatedFvsPatchField.H" #endif diff --git a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchFieldBase.C b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchFieldBase.C index 3abe281ccf..5375772156 100644 --- a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchFieldBase.C +++ b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchFieldBase.C @@ -83,7 +83,7 @@ void Foam::fvsPatchFieldBase::readDict(const dictionary& dict) const Foam::objectRegistry& Foam::fvsPatchFieldBase::db() const { - return patch_.boundaryMesh().mesh(); + return patch_.boundaryMesh().mesh().thisDb(); } diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C index 7a04296170..a8eccd2c9f 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -108,7 +108,9 @@ Foam::tmp Foam::cyclicFvPatch::interfaceInternalField const labelUList& faceCells ) const { - return patchInternalField(internalData, faceCells); + auto tpfld = tmp::New(); + patchInternalField(internalData, faceCells, tpfld.ref()); + return tpfld; } diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.C index 3e6db16b4d..8ddab7a43e 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation - Copyright (C) 2019,2022 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -295,7 +295,9 @@ Foam::tmp Foam::cyclicACMIFvPatch::interfaceInternalField const labelUList& faceCells ) const { - return patchInternalField(internalData, faceCells); + auto tpfld = tmp::New(); + patchInternalField(internalData, faceCells, tpfld.ref()); + return tpfld; } @@ -402,4 +404,5 @@ void Foam::cyclicACMIFvPatch::movePoints() } } + // ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C index 5b74ec455d..4bb5537ad3 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2020,2022 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -228,7 +228,9 @@ Foam::tmp Foam::cyclicAMIFvPatch::interfaceInternalField const labelUList& faceCells ) const { - return patchInternalField(internalData, faceCells); + auto tpfld = tmp::New(); + patchInternalField(internalData, faceCells, tpfld.ref()); + return tpfld; } diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/processor/processorFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/processor/processorFvPatch.C index dbf04fa225..2af6d7ee1a 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/processor/processorFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/processor/processorFvPatch.C @@ -117,7 +117,9 @@ Foam::tmp Foam::processorFvPatch::interfaceInternalField const labelUList& faceCells ) const { - return patchInternalField(internalData, faceCells); + auto tpfld = tmp::New(); + patchInternalField(internalData, faceCells, tpfld.ref()); + return tpfld; } diff --git a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H index 0e575be72d..b787c0e920 100644 --- a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2018 OpenFOAM Foundation - Copyright (C) 2020-2022 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,6 +33,8 @@ Description SourceFiles fvPatch.C fvPatchNew.C + fvPatchTemplates.C + fvPatchFvMeshTemplates.C \*---------------------------------------------------------------------------*/ @@ -274,32 +276,42 @@ public: // Evaluation Functions - //- Extract internal field next to patch using faceCells mapping + //- Extract internal field next to patch using specified addressing + // \param internalData The internal field to extract from + // \param addressing Addressing from patch into internal field + // \param [out] pfld The extracted patch field. + // It is always resized according to the patch size(), + // which can be smaller than the addressing size template inline void patchInternalField ( - const UList& f, - const labelUList& faceCells, + const UList& internalData, + const labelUList& addressing, + Field& pfld + ) const; + + //- Extract internal field next to patch as patch field + //- using faceCells() mapping. + // \param internalData The internal field to extract from + // \param [out] pfld The extracted patch field. + // It is always resized according to the patch size(), + // which can be smaller than the faceCells() size + template + void patchInternalField + ( + const UList& internalData, Field& pfld ) const; //- Return given internal field next to patch as patch field - template - tmp> patchInternalField(const UList&) const; - - //- Return given internal field next to patch as patch field - //- using provided addressing + //- using faceCells() mapping. + // \param internalData The internal field to extract from template tmp> patchInternalField ( - const UList& f, - const labelUList& faceCells + const UList& internalData ) const; - //- Return given internal field next to patch as patch field - template - void patchInternalField(const UList&, Field&) const; - //- Return the patch field of the GeometricField //- corresponding to this patch. template diff --git a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatchTemplates.C b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatchTemplates.C index 1b405d94a5..ec72dead9c 100644 --- a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatchTemplates.C +++ b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatchTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2022 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,53 +33,42 @@ License template void Foam::fvPatch::patchInternalField ( - const UList& f, - const labelUList& faceCells, + const UList& internalData, + const labelUList& addressing, Field& pfld ) const { - pfld.resize(size()); + const label len = this->size(); - forAll(pfld, i) + pfld.resize_nocopy(len); + + for (label i = 0; i < len; ++i) { - pfld[i] = f[faceCells[i]]; + pfld[i] = internalData[addressing[i]]; } } -template -Foam::tmp> Foam::fvPatch::patchInternalField -( - const UList& f -) const -{ - auto tpfld = tmp>::New(size()); - patchInternalField(f, this->faceCells(), tpfld.ref()); - return tpfld; -} - - -template -Foam::tmp> Foam::fvPatch::patchInternalField -( - const UList& f, - const labelUList& faceCells -) const -{ - auto tpfld = tmp>::New(size()); - patchInternalField(f, faceCells, tpfld.ref()); - return tpfld; -} - - template void Foam::fvPatch::patchInternalField ( - const UList& f, + const UList& internalData, Field& pfld ) const { - patchInternalField(f, this->faceCells(), pfld); + patchInternalField(internalData, this->faceCells(), pfld); +} + + +template +Foam::tmp> Foam::fvPatch::patchInternalField +( + const UList& internalData +) const +{ + auto tpfld = tmp>::New(); + patchInternalField(internalData, this->faceCells(), tpfld.ref()); + return tpfld; } diff --git a/src/overset/oversetPolyPatch/oversetFvPatch.C b/src/overset/oversetPolyPatch/oversetFvPatch.C index c1f4b68cf2..4abb67aa29 100644 --- a/src/overset/oversetPolyPatch/oversetFvPatch.C +++ b/src/overset/oversetPolyPatch/oversetFvPatch.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,7 +59,9 @@ Foam::tmp Foam::oversetFvPatch::interfaceInternalField const labelUList& faceCells ) const { - return patchInternalField(internalData, faceCells); + auto tpfld = tmp::New(); + patchInternalField(internalData, faceCells, tpfld.ref()); + return tpfld; } diff --git a/src/overset/oversetPolyPatch/oversetFvPatchField.H b/src/overset/oversetPolyPatch/oversetFvPatchField.H index 340132d94a..f681a9cd64 100644 --- a/src/overset/oversetPolyPatch/oversetFvPatchField.H +++ b/src/overset/oversetPolyPatch/oversetFvPatchField.H @@ -166,7 +166,7 @@ public: // Coupled and adjust flux //- Return neighbour field. Dummy - virtual tmp > patchNeighbourField() const; + virtual tmp> patchNeighbourField() const; //- Adjust psi for mass correction. Requires storeFringeCoefficients // to have been called before @@ -196,7 +196,7 @@ public: //- Return the matrix diagonal coefficients corresponding to the //- evaluation of the value of this patchField with given weights - virtual tmp > valueInternalCoeffs + virtual tmp> valueInternalCoeffs ( const tmp& ) const @@ -209,7 +209,7 @@ public: //- Return the matrix source coefficients corresponding to the //- evaluation of the value of this patchField with given weights - virtual tmp > valueBoundaryCoeffs + virtual tmp> valueBoundaryCoeffs ( const tmp& ) const @@ -222,7 +222,7 @@ public: //- Return the matrix diagonal coefficients corresponding to the //- evaluation of the gradient of this patchField - tmp > gradientInternalCoeffs() const + tmp> gradientInternalCoeffs() const { return tmp> ( @@ -232,7 +232,7 @@ public: //- Return the matrix source coefficients corresponding to the //- evaluation of the gradient of this patchField - tmp > gradientBoundaryCoeffs() const + tmp> gradientBoundaryCoeffs() const { return tmp> (