diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.H index bcbb710f85..5236bb5422 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.H @@ -178,8 +178,8 @@ public: // Access - //- Return size - label size() const + //- Return the field size + label size() const noexcept { return Field::size(); } diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H index 6a4d13d86e..a24e8b7aee 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H @@ -455,7 +455,7 @@ public: // Access //- Return the patch size - label size() const + label size() const noexcept { return patch().size(); } diff --git a/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C b/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C index 659a38d74b..4a7ab4d426 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C +++ b/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C @@ -568,6 +568,21 @@ Foam::label Foam::pointBoundaryMesh::findPatchID } +const Foam::pointPatch* +Foam::pointBoundaryMesh::cfindPatch(const word& patchName) const +{ + const pointPatchList& patches = *this; + + if (!patchName.empty()) + { + // Note: get() handles out-of-range access properly + return patches.get(PtrListOps::firstMatching(patches, patchName)); + } + + return nullptr; +} + + void Foam::pointBoundaryMesh::calcGeometry() { PstreamBuffers pBufs(Pstream::defaultCommsType); diff --git a/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.H b/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.H index 2adbdfbb1f..b3f10134be 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.H +++ b/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.H @@ -176,6 +176,10 @@ public: const bool allowNotFound = true ) const; + //- Find patch by name and return const pointer. + //- \returns nullptr if not found or for an empty patchName + const pointPatch* cfindPatch(const word& patchName) const; + //- The patch indices per patch group const HashTable& groupPatchIDs() const; diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C index ae3220526a..671d11d4be 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C @@ -957,7 +957,7 @@ void Foam::mapDistributeBase::distribute const label startOfRequests = UPstream::nRequests(); - if (!is_contiguous::value) + if constexpr (!is_contiguous_v) { PstreamBuffers pBufs(comm, tag); diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C index 8a6bf25f39..bc3611feb5 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C @@ -989,6 +989,21 @@ Foam::label Foam::polyBoundaryMesh::findPatchID } +const Foam::polyPatch* +Foam::polyBoundaryMesh::cfindPatch(const word& patchName) const +{ + const polyPatchList& patches = *this; + + if (!patchName.empty()) + { + // Note: get() handles out-of-range access properly + return patches.get(PtrListOps::firstMatching(patches, patchName)); + } + + return nullptr; +} + + Foam::labelPair Foam::polyBoundaryMesh::whichPatchFace(const label meshFacei) const { diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H index 35e21eee7d..f4059521f2 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H @@ -316,6 +316,10 @@ public: const bool allowNotFound = true ) const; + //- Find patch by name and return const pointer. + //- \returns nullptr on error or for an empty patchName + const polyPatch* cfindPatch(const word& patchName) const; + //- Find patch indices for a given polyPatch type (uses \c isA test). template labelHashSet findPatchIDs() const; diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H index 2b6d20eccd..1a4bb07235 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H @@ -411,15 +411,6 @@ public: return typename List::subList(values, this->size(), start_); } - //- This patch slice from the list of boundary values, which has size - //- mesh::nBoundaryFaces(), using the number of patch faces. - template - const typename List::subList - boundarySlice(const List& values) const - { - return typename List::subList(values, this->size(), offset()); - } - //- Slice Field to patch, using the number of patch faces. template const typename Field::subField @@ -428,6 +419,15 @@ public: return typename Field::subField(values, this->size(), start_); } + //- This patch slice from the list of boundary values, which has size + //- mesh::nBoundaryFaces(), using the number of patch faces. + template + const typename List::subList + boundarySlice(const UList& values) const + { + return typename List::subList(values, this->size(), offset()); + } + //- Write the polyPatch data as a dictionary virtual void write(Ostream& os) const; diff --git a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C index 08dd1d854b..37f1e934d4 100644 --- a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C +++ b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C @@ -784,6 +784,23 @@ Foam::label Foam::faBoundaryMesh::findPatchID } +const Foam::faPatch* Foam::faBoundaryMesh::cfindPatch +( + const word& patchName +) const +{ + const faPatchList& patches = *this; + + if (!patchName.empty()) + { + // Note: get() handles out-of-range access properly + return patches.get(PtrListOps::firstMatching(patches, patchName)); + } + + return nullptr; +} + + Foam::label Foam::faBoundaryMesh::whichPatch(const label edgeIndex) const { if (edgeIndex < mesh().nInternalEdges()) diff --git a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H index 1f173d9115..c351a9e1a8 100644 --- a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H +++ b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H @@ -269,6 +269,10 @@ public: const bool allowNotFound = true ) const; + //- Find patch by name and return const pointer. + //- \returns nullptr if not found or for an empty patchName + const faPatch* cfindPatch(const word& patchName) const; + //- Return patch index for a given edge label label whichPatch(const label edgeIndex) const; diff --git a/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H b/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H index 3bd84bc51a..ae4225444c 100644 --- a/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H +++ b/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H @@ -327,7 +327,8 @@ public: //- This patch slice from the complete list of values, which has //- size mesh::nEdges(), using the virtual patch size. template - const typename List::subList patchSlice(const List& values) const + const typename List::subList + patchSlice(const UList& values) const { return typename List::subList(values, size(), start()); } @@ -336,14 +337,9 @@ public: //- size mesh::nBoundaryEdges(), using the virtual patch size. template const typename List::subList - boundarySlice(const List& values) const + boundarySlice(const UList& values) const { - return typename List::subList - ( - values, - size(), - offset() - ); + return typename List::subList(values, size(), offset()); } diff --git a/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.C b/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.C index 9acff652b6..579d888a5e 100644 --- a/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.C +++ b/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2023 OpenCFD Ltd. + Copyright (C) 2018-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -114,6 +114,21 @@ Foam::label Foam::fvBoundaryMesh::findPatchID(const word& patchName) const } +const Foam::fvPatch* +Foam::fvBoundaryMesh::cfindPatch(const word& patchName) const +{ + const fvPatchList& patches = *this; + + if (!patchName.empty()) + { + // Note: get() handles out-of-range access properly + return patches.get(PtrListOps::firstMatching(patches, patchName)); + } + + return nullptr; +} + + void Foam::fvBoundaryMesh::movePoints() { fvPatchList& patches = *this; diff --git a/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.H b/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.H index ca814de78f..f6377f5a8a 100644 --- a/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.H +++ b/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.H @@ -143,6 +143,10 @@ public: // A no-op (returns -1) for an empty patchName label findPatchID(const word& patchName) const; + //- Find patch by name and return const pointer. + //- \returns nullptr if not found or for an empty patchName + const fvPatch* cfindPatch(const word& patchName) const; + //- Correct patches after moving points void movePoints(); diff --git a/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.C b/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.C index ce16d5ce4e..edfd04f6e9 100644 --- a/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.C +++ b/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.C @@ -64,10 +64,7 @@ void Foam::fvPatchMapper::calcAddressing() const // Direct mapping - slice to size directAddrPtr_ = std::make_unique ( - patch_.patchSlice - ( - static_cast(faceMap_.directAddressing()) - ) + patch_.patchSlice(faceMap_.directAddressing()) ); auto& addr = *directAddrPtr_; diff --git a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H index 3654ecb3fd..4343e17783 100644 --- a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H @@ -224,7 +224,7 @@ public: //- mesh::nFaces(), using the virtual patch size. template const typename List::subList - patchSlice(const List& values) const + patchSlice(const UList& values) const { return typename List::subList(values, size(), start()); } @@ -233,14 +233,9 @@ public: //- mesh::nBoundaryFaces(), using the virtual patch size. template const typename List::subList - boundarySlice(const List& values) const + boundarySlice(const UList& values) const { - return typename List::subList - ( - values, - size(), - polyPatch_.offset() - ); + return typename List::subList(values, size(), offset()); } //- Return faceCells diff --git a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C index 26120b67ce..f61d825240 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C @@ -76,18 +76,20 @@ void Foam::surfaceSlipDisplacementPointPatchVectorField::calcProjection // Get fixed points (bit of a hack) - const pointZone* zonePtr = nullptr; + const pointZone* zonePtr = mesh.pointZones().cfindZone(frozenPointsZone_); - if (frozenPointsZone_.size() > 0) + if (zonePtr) { - const pointZoneMesh& pZones = mesh.pointZones(); - - zonePtr = &pZones[frozenPointsZone_]; - Pout<< "surfaceSlipDisplacementPointPatchVectorField : Fixing all " << zonePtr->size() << " points in pointZone " << zonePtr->name() << endl; } + else if (!frozenPointsZone_.empty()) + { + FatalErrorInFunction + << "Cannot find frozen point zone: " << frozenPointsZone_ << nl + << exit(FatalError); + } // Get the starting locations from the motionSolver const pointField& points0 = mesh.lookupObject @@ -331,19 +333,20 @@ surfaceSlipDisplacementPointPatchVectorField ), wedgePlane_(dict.getOrDefault("wedgePlane", -1)), frozenPointsZone_(dict.getOrDefault("frozenPointsZone", word::null)), - scalePtr_ - ( - isA(p) - ? PatchFunction1::NewIfPresent - ( - refCast(p).patch(), - "scale", - dict, - false // point values - ) - : nullptr - ) -{} + scalePtr_(nullptr) +{ + if (const auto* fpp = isA(this->patch())) + { + scalePtr_ = + PatchFunction1::NewIfPresent + ( + fpp->patch(), + "scale", + dict, + false // point values (faceValues = false) + ); + } +} Foam::surfaceSlipDisplacementPointPatchVectorField:: @@ -361,37 +364,13 @@ surfaceSlipDisplacementPointPatchVectorField projectDir_(ppf.projectDir_), wedgePlane_(ppf.wedgePlane_), frozenPointsZone_(ppf.frozenPointsZone_), - scalePtr_ - ( - isA(p) - ? ppf.scalePtr_.clone(refCast(p).patch()) - : nullptr - ) -{} - - -Foam::surfaceSlipDisplacementPointPatchVectorField:: -surfaceSlipDisplacementPointPatchVectorField -( - const surfaceSlipDisplacementPointPatchVectorField& ppf -) -: - pointPatchVectorField(ppf), - surfacesDict_(ppf.surfacesDict_), - projectMode_(ppf.projectMode_), - projectDir_(ppf.projectDir_), - wedgePlane_(ppf.wedgePlane_), - frozenPointsZone_(ppf.frozenPointsZone_), - scalePtr_ - ( - isA(ppf.patch()) - ? ppf.scalePtr_.clone - ( - refCast(ppf.patch()).patch() - ) - : nullptr - ) -{} + scalePtr_(nullptr) +{ + if (const auto* fpp = isA(this->patch())) + { + scalePtr_ = ppf.scalePtr_.clone(fpp->patch()); + } +} Foam::surfaceSlipDisplacementPointPatchVectorField:: @@ -407,16 +386,13 @@ surfaceSlipDisplacementPointPatchVectorField projectDir_(ppf.projectDir_), wedgePlane_(ppf.wedgePlane_), frozenPointsZone_(ppf.frozenPointsZone_), - scalePtr_ - ( - isA(ppf.patch()) - ? ppf.scalePtr_.clone - ( - refCast(ppf.patch()).patch() - ) - : nullptr - ) -{} + scalePtr_(nullptr) +{ + if (const auto* fpp = isA(this->patch())) + { + scalePtr_ = ppf.scalePtr_.clone(fpp->patch()); + } +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // diff --git a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.H b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.H index a1a7eb2748..5eac2b964f 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.H +++ b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.H @@ -57,8 +57,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef surfaceSlipDisplacementPointPatchVectorField_H -#define surfaceSlipDisplacementPointPatchVectorField_H +#ifndef Foam_surfaceSlipDisplacementPointPatchVectorField_H +#define Foam_surfaceSlipDisplacementPointPatchVectorField_H #include "pointPatchFields.H" #include "searchableSurfaces.H" @@ -77,10 +77,9 @@ class surfaceSlipDisplacementPointPatchVectorField : public pointPatchVectorField { - public: - // Public data types + // Public Data Types enum projectMode { @@ -162,19 +161,27 @@ public: const pointPatchFieldMapper& ); - //- Construct as copy - surfaceSlipDisplacementPointPatchVectorField - ( - const surfaceSlipDisplacementPointPatchVectorField& - ); - - //- Construct as copy setting internal field reference + //- Copy construct with internal field reference surfaceSlipDisplacementPointPatchVectorField ( const surfaceSlipDisplacementPointPatchVectorField&, const DimensionedField& ); + //- Copy construct + surfaceSlipDisplacementPointPatchVectorField + ( + const surfaceSlipDisplacementPointPatchVectorField& pfld + ) + : + surfaceSlipDisplacementPointPatchVectorField + ( + pfld, + pfld.internalField() + ) + {} + + //- Return a clone virtual autoPtr> clone() const { diff --git a/src/meshTools/fields/pointPatchFields/uniformFixedValue/uniformFixedValuePointPatchField.C b/src/meshTools/fields/pointPatchFields/uniformFixedValue/uniformFixedValuePointPatchField.C index 0e35e0275d..07fc32d946 100644 --- a/src/meshTools/fields/pointPatchFields/uniformFixedValue/uniformFixedValuePointPatchField.C +++ b/src/meshTools/fields/pointPatchFields/uniformFixedValue/uniformFixedValuePointPatchField.C @@ -33,23 +33,23 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // // Alternative -// refCast(p).patch() +// { +// if (const auto* fpp = isA(p).patch()) +// { +// return fpp->patch(); +// } +// else +// { +// return nullptr; +// } +// } template const Foam::polyPatch* -Foam::uniformFixedValuePointPatchField::getPatch(const pointPatch& p) +Foam::uniformFixedValuePointPatchField::getPolyPatch(const pointPatch& p) { const polyMesh& mesh = p.boundaryMesh().mesh()(); - label patchi = mesh.boundaryMesh().findPatchID(p.name()); - - if (patchi == -1) - { - return nullptr; - } - else - { - return &mesh.boundaryMesh()[patchi]; - } + return mesh.boundaryMesh().cfindPatch(p.name()); } @@ -63,9 +63,7 @@ uniformFixedValuePointPatchField const DimensionedField& iF ) : - fixedValuePointPatchField(p, iF), - refValueFunc_(nullptr), - refPointValueFunc_(nullptr) + fixedValuePointPatchField(p, iF) {} @@ -78,31 +76,26 @@ uniformFixedValuePointPatchField const dictionary& dict ) : - fixedValuePointPatchField(p, iF, dict, IOobjectOption::NO_READ), - refValueFunc_ - ( - this->getPatch(p) - ? PatchFunction1::New - ( - *(this->getPatch(p)), - "uniformValue", - dict, - false // generate point values - ) - : nullptr - ), - refPointValueFunc_ - ( - this->getPatch(p) - ? nullptr - : Function1::New - ( - "uniformValue", - dict, - &this->internalField().db() - ) - ) + fixedValuePointPatchField(p, iF, dict, IOobjectOption::NO_READ) { + if (const polyPatch* pp = this->getPolyPatch(this->patch())) + { + refValueFunc_ = PatchFunction1::New + ( + *pp, + "uniformValue", + dict, + false // point values (faceValues = false) + ); + } + // Fallback + refPointValueFunc_ = Function1::New + ( + "uniformValue", + dict, + &this->internalField().db() + ); + if (!this->readValueEntry(dict)) { // Ensure field has reasonable initial values @@ -124,10 +117,15 @@ uniformFixedValuePointPatchField const pointPatchFieldMapper& mapper ) : - fixedValuePointPatchField(ptf, p, iF, mapper), - refValueFunc_(ptf.refValueFunc_.clone(*(this->getPatch(p)))), - refPointValueFunc_(ptf.refPointValueFunc_.clone()) + fixedValuePointPatchField(ptf, p, iF, mapper) { + if (const polyPatch* pp = this->getPolyPatch(this->patch())) + { + refValueFunc_ = ptf.refValueFunc_.clone(*pp); + } + // Fallback + refPointValueFunc_ = ptf.refPointValueFunc_.clone(); + if (mapper.direct() && !mapper.hasUnmapped()) { // Use mapping instead of re-evaluation @@ -145,27 +143,19 @@ template Foam::uniformFixedValuePointPatchField:: uniformFixedValuePointPatchField ( - const uniformFixedValuePointPatchField& ptf -) -: - fixedValuePointPatchField(ptf), - refValueFunc_(ptf.refValueFunc_.clone(*(this->getPatch(this->patch())))), - refPointValueFunc_(ptf.refPointValueFunc_.clone()) -{} - - -template -Foam::uniformFixedValuePointPatchField:: -uniformFixedValuePointPatchField -( - const uniformFixedValuePointPatchField& ptf, + const uniformFixedValuePointPatchField& pfld, const DimensionedField& iF ) : - fixedValuePointPatchField(ptf, iF), - refValueFunc_(ptf.refValueFunc_.clone(*(this->getPatch(this->patch())))), - refPointValueFunc_(ptf.refPointValueFunc_.clone()) -{} + fixedValuePointPatchField(pfld, iF) +{ + if (const polyPatch* pp = this->getPolyPatch(this->patch())) + { + refValueFunc_ = pfld.refValueFunc_.clone(*pp); + } + // Fallback + refPointValueFunc_ = pfld.refPointValueFunc_.clone(); +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -178,24 +168,31 @@ void Foam::uniformFixedValuePointPatchField::autoMap { fixedValuePointPatchField::autoMap(mapper); + bool canEvaluate(false); + if (refValueFunc_) { refValueFunc_().autoMap(mapper); - if (refValueFunc_().constant()) + // If mapper is not dependent on time we're ok to evaluate + if (refValueFunc_->constant()) { - // If mapper is not dependent on time we're ok to evaluate - this->evaluate(); + canEvaluate = true; } } if (refPointValueFunc_) { - if (refPointValueFunc_().constant()) + // If mapper is not dependent on time we're ok to evaluate + if (refPointValueFunc_->constant()) { - // If mapper is not dependent on time we're ok to evaluate - this->evaluate(); + canEvaluate = true; } } + + if (canEvaluate) + { + this->evaluate(); + } } @@ -208,8 +205,7 @@ void Foam::uniformFixedValuePointPatchField::rmap { fixedValuePointPatchField::rmap(ptf, addr); - const uniformFixedValuePointPatchField& tiptf = - refCast(ptf); + const auto& tiptf = refCast(ptf); if (refValueFunc_ && tiptf.refValueFunc_) { @@ -249,7 +245,7 @@ write(Ostream& os) const { refValueFunc_->writeData(os); } - if (refPointValueFunc_) + else if (refPointValueFunc_) { refPointValueFunc_->writeData(os); } diff --git a/src/meshTools/fields/pointPatchFields/uniformFixedValue/uniformFixedValuePointPatchField.H b/src/meshTools/fields/pointPatchFields/uniformFixedValue/uniformFixedValuePointPatchField.H index 3312fb063c..70ad3f3c7c 100644 --- a/src/meshTools/fields/pointPatchFields/uniformFixedValue/uniformFixedValuePointPatchField.H +++ b/src/meshTools/fields/pointPatchFields/uniformFixedValue/uniformFixedValuePointPatchField.H @@ -92,7 +92,8 @@ class uniformFixedValuePointPatchField // Private Member Functions - static const polyPatch* getPatch(const pointPatch&); + //- Find polyPatch with the same name as the pointPatch + static const polyPatch* getPolyPatch(const pointPatch& p); public: @@ -127,19 +128,22 @@ public: const pointPatchFieldMapper& ); - //- Construct as copy - uniformFixedValuePointPatchField - ( - const uniformFixedValuePointPatchField& - ); - - //- Construct as copy setting internal field reference + //- Copy construct with internal field reference uniformFixedValuePointPatchField ( const uniformFixedValuePointPatchField&, const DimensionedField& ); + //- Copy construct + uniformFixedValuePointPatchField + ( + const uniformFixedValuePointPatchField& pfld + ) + : + uniformFixedValuePointPatchField(pfld, pfld.internalField()) + {} + //- Return a clone virtual autoPtr> clone() const diff --git a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C index be8b4aab60..b329596a72 100644 --- a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C +++ b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C @@ -295,18 +295,12 @@ bool Foam::movingConeTopoFvMesh::init(const bool doInit) curLeft_ = average ( - faceZones() - [ - faceZones().findZoneID("leftExtrusionFaces") - ]().localPoints() + faceZones()["leftExtrusionFaces"].patch().localPoints() ).x() - SMALL; curRight_ = average ( - faceZones() - [ - faceZones().findZoneID("rightExtrusionFaces") - ]().localPoints() + faceZones()["rightExtrusionFaces"].patch().localPoints() ).x() + SMALL; motionMask_ = vertexMarkup @@ -407,18 +401,12 @@ bool Foam::movingConeTopoFvMesh::update() curLeft_ = average ( - faceZones() - [ - faceZones().findZoneID("leftExtrusionFaces") - ]().localPoints() + faceZones()["leftExtrusionFaces"].patch().localPoints() ).x() - SMALL; curRight_ = average ( - faceZones() - [ - faceZones().findZoneID("rightExtrusionFaces") - ]().localPoints() + faceZones()["rightExtrusionFaces"].patch().localPoints() ).x() + SMALL; return true;