ENH: avoid faPatch/fvPatch patchInternalField ambiguity

- with alternative faceCell addressing, use the three-parameter
  version only. This avoids potential future ambiguity with the
  two-parameter version (eg, with a label type)

ENH: add faPatchField patchInternalField() for symmetry with fvPatchField

ENH: direct reference to mesh thisDb instead of inferring

ENH: pointMesh::boundaryMesh() method (eg, similar to fvMesh)
This commit is contained in:
Mark Olesen
2023-01-02 09:33:00 +01:00
parent bd0ad07d40
commit bf99c104eb
31 changed files with 222 additions and 217 deletions

View File

@ -122,7 +122,7 @@ Foam::tmp<Foam::Field<Type1>>
Foam::pointPatchField<Type>::patchInternalField Foam::pointPatchField<Type>::patchInternalField
( (
const Field<Type1>& iF, const Field<Type1>& iF,
const labelList& meshPoints const labelUList& meshPoints
) const ) const
{ {
// Check size // Check size
@ -194,7 +194,7 @@ void Foam::pointPatchField<Type>::addToInternalField
( (
Field<Type1>& iF, Field<Type1>& iF,
const Field<Type1>& pF, const Field<Type1>& pF,
const labelList& points const labelUList& points
) const ) const
{ {
// Check size // Check size
@ -233,7 +233,7 @@ void Foam::pointPatchField<Type>::setInInternalField
( (
Field<Type1>& iF, Field<Type1>& iF,
const Field<Type1>& pF, const Field<Type1>& pF,
const labelList& meshPoints const labelUList& meshPoints
) const ) const
{ {
// Check size // Check size
@ -310,8 +310,4 @@ Foam::Ostream& Foam::operator<<
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "pointPatchFieldNew.C"
// ************************************************************************* // // ************************************************************************* //

View File

@ -390,24 +390,27 @@ public:
return patch().size(); return patch().size();
} }
//- Return dimensioned internal field reference //- Return const-reference to the dimensioned internal field
const DimensionedField<Type, pointMesh>& internalField() const DimensionedField<Type, pointMesh>& internalField()
const noexcept const noexcept
{ {
return internalField_; return internalField_;
} }
//- Return internal field reference //- Return const-reference to the internal field values
const Field<Type>& primitiveField() const noexcept const Field<Type>& primitiveField() const noexcept
{ {
return internalField_; return internalField_;
} }
// Evaluation Functions
//- Return field created from appropriate internal field values //- Return field created from appropriate internal field values
tmp<Field<Type>> patchInternalField() const; tmp<Field<Type>> patchInternalField() const;
//- Return field created from appropriate internal field values //- Return field created from appropriate internal field values
// given internal field reference //- given internal field reference
template<class Type1> template<class Type1>
tmp<Field<Type1>> patchInternalField tmp<Field<Type1>> patchInternalField
( (
@ -415,16 +418,16 @@ public:
) const; ) const;
//- Return field created from selected internal field values //- Return field created from selected internal field values
// given internal field reference //- given internal field reference
template<class Type1> template<class Type1>
tmp<Field<Type1>> patchInternalField tmp<Field<Type1>> patchInternalField
( (
const Field<Type1>& iF, const Field<Type1>& iF,
const labelList& meshPoints const labelUList& meshPoints
) const; ) const;
//- Given the internal field and a patch field, //- 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<class Type1> template<class Type1>
void addToInternalField void addToInternalField
( (
@ -433,27 +436,27 @@ public:
) const; ) const;
//- Given the internal field and a patch field, //- 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<class Type1> template<class Type1>
void addToInternalField void addToInternalField
( (
Field<Type1>& iF, Field<Type1>& iF,
const Field<Type1>& pF, const Field<Type1>& pF,
const labelList& points const labelUList& points
) const; ) const;
//- Given the internal field and a patch field, //- 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<class Type1> template<class Type1>
void setInInternalField void setInInternalField
( (
Field<Type1>& iF, Field<Type1>& iF,
const Field<Type1>& pF, const Field<Type1>& pF,
const labelList& meshPoints const labelUList& meshPoints
) const; ) const;
//- Given the internal field and a patch field, //- 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<class Type1> template<class Type1>
void setInInternalField void setInInternalField
( (
@ -581,6 +584,7 @@ const pointPatchField<Type>& operator+
#ifdef NoRepository #ifdef NoRepository
#include "pointPatchField.C" #include "pointPatchField.C"
#include "pointPatchFieldNew.C"
#include "calculatedPointPatchField.H" #include "calculatedPointPatchField.H"
#include "zeroGradientPointPatchField.H" #include "zeroGradientPointPatchField.H"
#endif #endif

View File

@ -105,7 +105,7 @@ void Foam::pointPatchFieldBase::readDict(const dictionary& dict)
const Foam::objectRegistry& Foam::pointPatchFieldBase::db() const const Foam::objectRegistry& Foam::pointPatchFieldBase::db() const
{ {
return patch_.boundaryMesh().mesh()(); return patch_.boundaryMesh().mesh().thisDb();
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd. Copyright (C) 2018-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -67,7 +67,7 @@ Foam::labelList Foam::pointBoundaryMesh::indices
const bool useGroups const bool useGroups
) const ) 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 bool useGroups
) const ) const
{ {
return mesh()().boundaryMesh().indices(matcher, useGroups); return mesh().boundaryMesh().indices(matcher, useGroups);
} }
Foam::label Foam::pointBoundaryMesh::findPatchID(const word& patchName) const Foam::label Foam::pointBoundaryMesh::findPatchID(const word& patchName) const
{ {
return mesh()().boundaryMesh().findPatchID(patchName); return mesh().boundaryMesh().findPatchID(patchName);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd. Copyright (C) 2021-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -112,7 +112,7 @@ public:
} }
//- Return reference to boundary mesh //- Return reference to boundary mesh
const pointBoundaryMesh& boundary() const const pointBoundaryMesh& boundary() const noexcept
{ {
return boundary_; return boundary_;
} }
@ -136,7 +136,16 @@ public:
} }
// Mesh motion // Volume Mesh
//- Return boundary mesh for underlying volume mesh
const polyBoundaryMesh& boundaryMesh() const
{
return GeoMesh<polyMesh>::mesh_.boundaryMesh();
}
// Mesh Motion
//- Move points //- Move points
bool movePoints(); bool movePoints();

View File

@ -321,7 +321,9 @@ Foam::tmp<Foam::labelField> Foam::cyclicFaPatch::interfaceInternalField
const labelUList& edgeFaces const labelUList& edgeFaces
) const ) const
{ {
return patchInternalField(internalData, edgeFaces); auto tpfld = tmp<labelField>::New();
patchInternalField(internalData, edgeFaces, tpfld.ref());
return tpfld;
} }

View File

@ -492,7 +492,9 @@ Foam::tmp<Foam::labelField> Foam::processorFaPatch::interfaceInternalField
const labelUList& edgeFaces const labelUList& edgeFaces
) const ) const
{ {
return patchInternalField(internalData, edgeFaces); auto tpfld = tmp<labelField>::New();
patchInternalField(internalData, edgeFaces, tpfld.ref());
return tpfld;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2020-2022 OpenCFD Ltd. Copyright (C) 2020-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -421,32 +421,42 @@ public:
// Evaluation // 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<class Type> template<class Type>
inline void patchInternalField inline void patchInternalField
( (
const UList<Type>& f, const UList<Type>& internalData,
const labelUList& edgeFaces, const labelUList& addressing,
Field<Type>& 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<class Type>
void patchInternalField
(
const UList<Type>& internalData,
Field<Type>& pfld Field<Type>& pfld
) const; ) const;
//- Return given internal field next to patch as patch field //- Return given internal field next to patch as patch field
//- using edgeFaces() mapping.
// \param internalData The internal field to extract from
template<class Type> template<class Type>
tmp<Field<Type>> patchInternalField(const UList<Type>&) const; tmp<Field<Type>> patchInternalField
//- Return given internal field next to patch as patch field
//- using provided addressing
template<class Type>
tmp<Foam::Field<Type>> patchInternalField
( (
const UList<Type>& f, const UList<Type>& internalData
const labelUList& edgeFaces
) const; ) const;
//- Extract internal field next to patch as patch field
template<class Type>
void patchInternalField(const UList<Type>&, Field<Type>&) const;
//- Return the patch field of the GeometricField //- Return the patch field of the GeometricField
//- corresponding to this patch. //- corresponding to this patch.
template<class GeometricField, class AnyType = bool> template<class GeometricField, class AnyType = bool>

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2019-2022 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -33,53 +33,42 @@ License
template<class Type> template<class Type>
void Foam::faPatch::patchInternalField void Foam::faPatch::patchInternalField
( (
const UList<Type>& f, const UList<Type>& internalData,
const labelUList& edgeFaces, const labelUList& addressing,
Field<Type>& pfld Field<Type>& pfld
) const ) 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<class Type>
Foam::tmp<Foam::Field<Type>> Foam::faPatch::patchInternalField
(
const UList<Type>& f
) const
{
auto tpfld = tmp<Field<Type>>::New(size());
patchInternalField(f, this->edgeFaces(), tpfld.ref());
return tpfld;
}
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::faPatch::patchInternalField
(
const UList<Type>& f,
const labelUList& edgeFaces
) const
{
auto tpfld = tmp<Field<Type>>::New(size());
patchInternalField(f, edgeFaces, tpfld.ref());
return tpfld;
}
template<class Type> template<class Type>
void Foam::faPatch::patchInternalField void Foam::faPatch::patchInternalField
( (
const UList<Type>& f, const UList<Type>& internalData,
Field<Type>& pfld Field<Type>& pfld
) const ) const
{ {
patchInternalField(f, this->edgeFaces(), pfld); patchInternalField(internalData, this->edgeFaces(), pfld);
}
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::faPatch::patchInternalField
(
const UList<Type>& internalData
) const
{
auto tpfld = tmp<Field<Type>>::New();
patchInternalField(internalData, this->edgeFaces(), tpfld.ref());
return tpfld;
} }

View File

@ -128,18 +128,17 @@ void clampedPlateFaPatchField<scalar>::evaluate(const Pstream::commsTypes)
template<class Type> template<class Type>
tmp<Field<Type> > clampedPlateFaPatchField<Type>::valueInternalCoeffs tmp<Field<Type>> clampedPlateFaPatchField<Type>::valueInternalCoeffs
( (
const tmp<scalarField>& const tmp<scalarField>&
) const ) const
{ {
return tmp<Field<Type>> return tmp<Field<Type>>::New(this->size(), Zero);
(new Field<Type>(this->size(), pTraits<Type>::zero));
} }
template<class Type> template<class Type>
tmp<Field<Type> > clampedPlateFaPatchField<Type>::valueBoundaryCoeffs tmp<Field<Type>> clampedPlateFaPatchField<Type>::valueBoundaryCoeffs
( (
const tmp<scalarField>& const tmp<scalarField>&
) const ) const
@ -149,7 +148,7 @@ tmp<Field<Type> > clampedPlateFaPatchField<Type>::valueBoundaryCoeffs
template<class Type> template<class Type>
tmp<Field<Type> > tmp<Field<Type>>
clampedPlateFaPatchField<Type>::gradientInternalCoeffs() const clampedPlateFaPatchField<Type>::gradientInternalCoeffs() const
{ {
return -Type(pTraits<Type>::one)*this->patch().deltaCoeffs(); return -Type(pTraits<Type>::one)*this->patch().deltaCoeffs();
@ -157,7 +156,7 @@ clampedPlateFaPatchField<Type>::gradientInternalCoeffs() const
template<class Type> template<class Type>
tmp<Field<Type> > tmp<Field<Type>>
clampedPlateFaPatchField<Type>::gradientBoundaryCoeffs() const clampedPlateFaPatchField<Type>::gradientBoundaryCoeffs() const
{ {
return this->patch().deltaCoeffs()*(*this); return this->patch().deltaCoeffs()*(*this);

View File

@ -131,12 +131,12 @@ public:
); );
//- Construct and return a clone setting internal field reference //- Construct and return a clone setting internal field reference
virtual tmp<faPatchField<Type> > clone virtual tmp<faPatchField<Type>> clone
( (
const DimensionedField<Type, areaMesh>& iF const DimensionedField<Type, areaMesh>& iF
) const ) const
{ {
return tmp<faPatchField<Type> > return tmp<faPatchField<Type>>
( (
new clampedPlateFaPatchField<Type>(*this, iF) new clampedPlateFaPatchField<Type>(*this, iF)
); );
@ -169,25 +169,25 @@ public:
//- Return the matrix diagonal coefficients corresponding to the //- Return the matrix diagonal coefficients corresponding to the
//- evaluation of the value of this patchField with given weights //- evaluation of the value of this patchField with given weights
virtual tmp<Field<Type> > valueInternalCoeffs virtual tmp<Field<Type>> valueInternalCoeffs
( (
const tmp<scalarField>& const tmp<scalarField>&
) const; ) const;
//- Return the matrix source coefficients corresponding to the //- Return the matrix source coefficients corresponding to the
//- evaluation of the value of this patchField with given weights //- evaluation of the value of this patchField with given weights
virtual tmp<Field<Type> > valueBoundaryCoeffs virtual tmp<Field<Type>> valueBoundaryCoeffs
( (
const tmp<scalarField>& const tmp<scalarField>&
) const; ) const;
//- Return the matrix diagonal coefficients corresponding to the //- Return the matrix diagonal coefficients corresponding to the
//- evaluation of the gradient of this patchField //- evaluation of the gradient of this patchField
virtual tmp<Field<Type> > gradientInternalCoeffs() const; virtual tmp<Field<Type>> gradientInternalCoeffs() const;
//- Return the matrix source coefficients corresponding to the //- Return the matrix source coefficients corresponding to the
//- evaluation of the gradient of this patchField //- evaluation of the gradient of this patchField
virtual tmp<Field<Type> > gradientBoundaryCoeffs() const; virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
// IO // IO

View File

@ -128,14 +128,6 @@ Foam::faPatchField<Type>::faPatchField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
const Foam::objectRegistry& Foam::faPatchField<Type>::db() const
{
// Note: Lookup fields from the field DB rather than the mesh
return internalField_.db();
}
template<class Type> template<class Type>
void Foam::faPatchField<Type>::check(const faPatchField<Type>& rhs) const void Foam::faPatchField<Type>::check(const faPatchField<Type>& rhs) const
{ {
@ -158,6 +150,13 @@ Foam::faPatchField<Type>::patchInternalField() const
} }
template<class Type>
void Foam::faPatchField<Type>::patchInternalField(Field<Type>& pfld) const
{
patch().patchInternalField(internalField_, pfld);
}
template<class Type> template<class Type>
void Foam::faPatchField<Type>::autoMap(const faPatchFieldMapper& m) void Foam::faPatchField<Type>::autoMap(const faPatchFieldMapper& m)
{ {
@ -407,8 +406,4 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const faPatchField<Type>& ptf)
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "faPatchFieldNew.C"
// ************************************************************************* // // ************************************************************************* //

View File

@ -143,7 +143,7 @@ public:
// Access // Access
//- The associated objectRegistry //- The associated objectRegistry
/// const objectRegistry& db() const; const objectRegistry& db() const;
//- Return the patch //- Return the patch
const faPatch& patch() const noexcept const faPatch& patch() const noexcept
@ -394,17 +394,14 @@ public:
// Access // Access
//- Return local objectRegistry //- Return const-reference to the dimensioned internal field
const objectRegistry& db() const; const DimensionedField<Type, areaMesh>& internalField()
const noexcept
//- Return dimensioned internal field reference
const DimensionedField<Type, areaMesh>&
internalField() const noexcept
{ {
return internalField_; return internalField_;
} }
//- Return internal field reference //- Return const-reference to the internal field values
const Field<Type>& primitiveField() const noexcept const Field<Type>& primitiveField() const noexcept
{ {
return internalField_; return internalField_;
@ -432,9 +429,13 @@ public:
//- Return patch-normal gradient //- Return patch-normal gradient
virtual tmp<Field<Type>> snGrad() const; virtual tmp<Field<Type>> snGrad() const;
//- Return internal field next to patch as patch field //- Return internal field next to patch
virtual tmp<Field<Type>> patchInternalField() const; virtual tmp<Field<Type>> patchInternalField() const;
//- Extract internal field next to patch
// \param [out] pfld The extracted patch field.
virtual void patchInternalField(Field<Type>& pfld) const;
//- Return patchField on the opposite patch of a coupled patch //- Return patchField on the opposite patch of a coupled patch
virtual tmp<Field<Type>> patchNeighbourField() const virtual tmp<Field<Type>> patchNeighbourField() const
{ {
@ -556,6 +557,7 @@ public:
#ifdef NoRepository #ifdef NoRepository
#include "faPatchField.C" #include "faPatchField.C"
#include "faPatchFieldNew.C"
#include "calculatedFaPatchField.H" #include "calculatedFaPatchField.H"
#include "zeroGradientFaPatchField.H" #include "zeroGradientFaPatchField.H"
#endif #endif

View File

@ -26,6 +26,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "faPatchField.H" #include "faPatchField.H"
#include "faBoundaryMesh.H"
#include "faMesh.H"
#include "dictionary.H" #include "dictionary.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -103,10 +105,10 @@ void Foam::faPatchFieldBase::readDict(const dictionary& dict)
} }
// const Foam::objectRegistry& Foam::faPatchFieldBase::db() const const Foam::objectRegistry& Foam::faPatchFieldBase::db() const
// { {
// return patch_.boundaryMesh().mesh().thisDb(); return patch_.boundaryMesh().mesh().thisDb();
// } }
void Foam::faPatchFieldBase::checkPatch(const faPatchFieldBase& rhs) const void Foam::faPatchFieldBase::checkPatch(const faPatchFieldBase& rhs) const

View File

@ -125,14 +125,6 @@ Foam::faePatchField<Type>::faePatchField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
const Foam::objectRegistry& Foam::faePatchField<Type>::db() const
{
// Note: Lookup fields from the field DB rather than the mesh
return internalField_.db();
}
template<class Type> template<class Type>
void Foam::faePatchField<Type>::check(const faePatchField<Type>& rhs) const void Foam::faePatchField<Type>::check(const faePatchField<Type>& rhs) const
{ {
@ -373,8 +365,4 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const faePatchField<Type>& ptf)
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "faePatchFieldNew.C"
// ************************************************************************* // // ************************************************************************* //

View File

@ -128,7 +128,7 @@ public:
// Access // Access
//- The associated objectRegistry //- The associated objectRegistry
/// const objectRegistry& db() const; const objectRegistry& db() const;
//- Return the patch //- Return the patch
const faPatch& patch() const noexcept const faPatch& patch() const noexcept
@ -358,17 +358,14 @@ public:
// Access // Access
//- Return local objectRegistry //- Return const-reference to the dimensioned internal field
const objectRegistry& db() const;
//- Return dimensioned internal field reference
const DimensionedField<Type, edgeMesh>& internalField() const DimensionedField<Type, edgeMesh>& internalField()
const noexcept const noexcept
{ {
return internalField_; return internalField_;
} }
//- Return internal field reference //- Return const-reference to the internal field values
const Field<Type>& primitiveField() const noexcept const Field<Type>& primitiveField() const noexcept
{ {
return internalField_; return internalField_;
@ -445,6 +442,7 @@ public:
#ifdef NoRepository #ifdef NoRepository
#include "faePatchField.C" #include "faePatchField.C"
#include "faePatchFieldNew.C"
#include "calculatedFaePatchField.H" #include "calculatedFaePatchField.H"
#endif #endif

View File

@ -26,6 +26,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "faePatchField.H" #include "faePatchField.H"
#include "faBoundaryMesh.H"
#include "faMesh.H"
#include "dictionary.H" #include "dictionary.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -93,10 +95,10 @@ void Foam::faePatchFieldBase::readDict(const dictionary& dict)
{} {}
// const Foam::objectRegistry& Foam::faePatchFieldBase::db() const const Foam::objectRegistry& Foam::faePatchFieldBase::db() const
// { {
// return patch_.boundaryMesh().mesh().thisDb(); return patch_.boundaryMesh().mesh().thisDb();
// } }
void Foam::faePatchFieldBase::checkPatch(const faePatchFieldBase& rhs) const void Foam::faePatchFieldBase::checkPatch(const faePatchFieldBase& rhs) const

View File

@ -193,9 +193,9 @@ Foam::fvPatchField<Type>::patchInternalField() const
template<class Type> template<class Type>
void Foam::fvPatchField<Type>::patchInternalField(Field<Type>& pif) const void Foam::fvPatchField<Type>::patchInternalField(Field<Type>& pfld) const
{ {
patch().patchInternalField(internalField_, pif); patch().patchInternalField(internalField_, pfld);
} }
@ -552,8 +552,4 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const fvPatchField<Type>& ptf)
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "fvPatchFieldNew.C"
// ************************************************************************* // // ************************************************************************* //

View File

@ -461,14 +461,14 @@ public:
// Access // Access
//- Return dimensioned internal field reference //- Return const-reference to the dimensioned internal field
const DimensionedField<Type, volMesh>& internalField() const DimensionedField<Type, volMesh>& internalField()
const noexcept const noexcept
{ {
return internalField_; return internalField_;
} }
//- Return internal field reference //- Return const-reference to the internal field values
const Field<Type>& primitiveField() const noexcept const Field<Type>& primitiveField() const noexcept
{ {
return internalField_; return internalField_;
@ -517,11 +517,12 @@ public:
// patches. Sets Updated to true // patches. Sets Updated to true
virtual void updateWeightedCoeffs(const scalarField& weights); virtual void updateWeightedCoeffs(const scalarField& weights);
//- Return internal field next to patch as patch field //- Return internal field next to patch
virtual tmp<Field<Type>> patchInternalField() const; virtual tmp<Field<Type>> patchInternalField() const;
//- Return internal field next to patch as patch field //- Extract internal field next to patch
virtual void patchInternalField(Field<Type>&) const; // \param [out] pfld The extracted patch field.
virtual void patchInternalField(Field<Type>& pfld) const;
//- Return patchField on the opposite patch of a coupled patch //- Return patchField on the opposite patch of a coupled patch
virtual tmp<Field<Type>> patchNeighbourField() const virtual tmp<Field<Type>> patchNeighbourField() const
@ -684,6 +685,7 @@ public:
#ifdef NoRepository #ifdef NoRepository
#include "fvPatchField.C" #include "fvPatchField.C"
#include "fvPatchFieldNew.C"
#include "calculatedFvPatchField.H" #include "calculatedFvPatchField.H"
#include "zeroGradientFvPatchField.H" #include "zeroGradientFvPatchField.H"
#endif #endif

View File

@ -112,7 +112,7 @@ void Foam::fvPatchFieldBase::readDict(const dictionary& dict)
const Foam::objectRegistry& Foam::fvPatchFieldBase::db() const const Foam::objectRegistry& Foam::fvPatchFieldBase::db() const
{ {
return patch_.boundaryMesh().mesh(); return patch_.boundaryMesh().mesh().thisDb();
} }

View File

@ -365,8 +365,4 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const fvsPatchField<Type>& ptf)
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "fvsPatchFieldNew.C"
// ************************************************************************* // // ************************************************************************* //

View File

@ -357,14 +357,14 @@ public:
// Access // Access
//- Return dimensioned internal field reference //- Return const-reference to the dimensioned internal field
const DimensionedField<Type, surfaceMesh>& internalField() const DimensionedField<Type, surfaceMesh>& internalField()
const noexcept const noexcept
{ {
return internalField_; return internalField_;
} }
//- Return internal field reference //- Return const-reference to the internal field values
const Field<Type>& primitiveField() const noexcept const Field<Type>& primitiveField() const noexcept
{ {
return internalField_; return internalField_;
@ -441,6 +441,7 @@ public:
#ifdef NoRepository #ifdef NoRepository
#include "fvsPatchField.C" #include "fvsPatchField.C"
#include "fvsPatchFieldNew.C"
#include "calculatedFvsPatchField.H" #include "calculatedFvsPatchField.H"
#endif #endif

View File

@ -83,7 +83,7 @@ void Foam::fvsPatchFieldBase::readDict(const dictionary& dict)
const Foam::objectRegistry& Foam::fvsPatchFieldBase::db() const const Foam::objectRegistry& Foam::fvsPatchFieldBase::db() const
{ {
return patch_.boundaryMesh().mesh(); return patch_.boundaryMesh().mesh().thisDb();
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -108,7 +108,9 @@ Foam::tmp<Foam::labelField> Foam::cyclicFvPatch::interfaceInternalField
const labelUList& faceCells const labelUList& faceCells
) const ) const
{ {
return patchInternalField(internalData, faceCells); auto tpfld = tmp<labelField>::New();
patchInternalField(internalData, faceCells, tpfld.ref());
return tpfld;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2019,2022 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -295,7 +295,9 @@ Foam::tmp<Foam::labelField> Foam::cyclicACMIFvPatch::interfaceInternalField
const labelUList& faceCells const labelUList& faceCells
) const ) const
{ {
return patchInternalField(internalData, faceCells); auto tpfld = tmp<labelField>::New();
patchInternalField(internalData, faceCells, tpfld.ref());
return tpfld;
} }
@ -402,4 +404,5 @@ void Foam::cyclicACMIFvPatch::movePoints()
} }
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020,2022 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -228,7 +228,9 @@ Foam::tmp<Foam::labelField> Foam::cyclicAMIFvPatch::interfaceInternalField
const labelUList& faceCells const labelUList& faceCells
) const ) const
{ {
return patchInternalField(internalData, faceCells); auto tpfld = tmp<labelField>::New();
patchInternalField(internalData, faceCells, tpfld.ref());
return tpfld;
} }

View File

@ -117,7 +117,9 @@ Foam::tmp<Foam::labelField> Foam::processorFvPatch::interfaceInternalField
const labelUList& faceCells const labelUList& faceCells
) const ) const
{ {
return patchInternalField(internalData, faceCells); auto tpfld = tmp<labelField>::New();
patchInternalField(internalData, faceCells, tpfld.ref());
return tpfld;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2018 OpenFOAM Foundation Copyright (C) 2011-2018 OpenFOAM Foundation
Copyright (C) 2020-2022 OpenCFD Ltd. Copyright (C) 2020-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -33,6 +33,8 @@ Description
SourceFiles SourceFiles
fvPatch.C fvPatch.C
fvPatchNew.C fvPatchNew.C
fvPatchTemplates.C
fvPatchFvMeshTemplates.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -274,32 +276,42 @@ public:
// Evaluation Functions // 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<class Type> template<class Type>
inline void patchInternalField inline void patchInternalField
( (
const UList<Type>& f, const UList<Type>& internalData,
const labelUList& faceCells, const labelUList& addressing,
Field<Type>& 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<class Type>
void patchInternalField
(
const UList<Type>& internalData,
Field<Type>& pfld Field<Type>& pfld
) const; ) const;
//- Return given internal field next to patch as patch field //- Return given internal field next to patch as patch field
template<class Type> //- using faceCells() mapping.
tmp<Field<Type>> patchInternalField(const UList<Type>&) const; // \param internalData The internal field to extract from
//- Return given internal field next to patch as patch field
//- using provided addressing
template<class Type> template<class Type>
tmp<Field<Type>> patchInternalField tmp<Field<Type>> patchInternalField
( (
const UList<Type>& f, const UList<Type>& internalData
const labelUList& faceCells
) const; ) const;
//- Return given internal field next to patch as patch field
template<class Type>
void patchInternalField(const UList<Type>&, Field<Type>&) const;
//- Return the patch field of the GeometricField //- Return the patch field of the GeometricField
//- corresponding to this patch. //- corresponding to this patch.
template<class GeometricField, class AnyType = bool> template<class GeometricField, class AnyType = bool>

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2022 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -33,53 +33,42 @@ License
template<class Type> template<class Type>
void Foam::fvPatch::patchInternalField void Foam::fvPatch::patchInternalField
( (
const UList<Type>& f, const UList<Type>& internalData,
const labelUList& faceCells, const labelUList& addressing,
Field<Type>& pfld Field<Type>& pfld
) const ) 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<class Type>
Foam::tmp<Foam::Field<Type>> Foam::fvPatch::patchInternalField
(
const UList<Type>& f
) const
{
auto tpfld = tmp<Field<Type>>::New(size());
patchInternalField(f, this->faceCells(), tpfld.ref());
return tpfld;
}
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::fvPatch::patchInternalField
(
const UList<Type>& f,
const labelUList& faceCells
) const
{
auto tpfld = tmp<Field<Type>>::New(size());
patchInternalField(f, faceCells, tpfld.ref());
return tpfld;
}
template<class Type> template<class Type>
void Foam::fvPatch::patchInternalField void Foam::fvPatch::patchInternalField
( (
const UList<Type>& f, const UList<Type>& internalData,
Field<Type>& pfld Field<Type>& pfld
) const ) const
{ {
patchInternalField(f, this->faceCells(), pfld); patchInternalField(internalData, this->faceCells(), pfld);
}
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::fvPatch::patchInternalField
(
const UList<Type>& internalData
) const
{
auto tpfld = tmp<Field<Type>>::New();
patchInternalField(internalData, this->faceCells(), tpfld.ref());
return tpfld;
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2021 OpenCFD Ltd. Copyright (C) 2016-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -59,7 +59,9 @@ Foam::tmp<Foam::labelField> Foam::oversetFvPatch::interfaceInternalField
const labelUList& faceCells const labelUList& faceCells
) const ) const
{ {
return patchInternalField(internalData, faceCells); auto tpfld = tmp<labelField>::New();
patchInternalField(internalData, faceCells, tpfld.ref());
return tpfld;
} }

View File

@ -166,7 +166,7 @@ public:
// Coupled and adjust flux // Coupled and adjust flux
//- Return neighbour field. Dummy //- Return neighbour field. Dummy
virtual tmp<Field<Type> > patchNeighbourField() const; virtual tmp<Field<Type>> patchNeighbourField() const;
//- Adjust psi for mass correction. Requires storeFringeCoefficients //- Adjust psi for mass correction. Requires storeFringeCoefficients
// to have been called before // to have been called before
@ -196,7 +196,7 @@ public:
//- Return the matrix diagonal coefficients corresponding to the //- Return the matrix diagonal coefficients corresponding to the
//- evaluation of the value of this patchField with given weights //- evaluation of the value of this patchField with given weights
virtual tmp<Field<Type> > valueInternalCoeffs virtual tmp<Field<Type>> valueInternalCoeffs
( (
const tmp<scalarField>& const tmp<scalarField>&
) const ) const
@ -209,7 +209,7 @@ public:
//- Return the matrix source coefficients corresponding to the //- Return the matrix source coefficients corresponding to the
//- evaluation of the value of this patchField with given weights //- evaluation of the value of this patchField with given weights
virtual tmp<Field<Type> > valueBoundaryCoeffs virtual tmp<Field<Type>> valueBoundaryCoeffs
( (
const tmp<scalarField>& const tmp<scalarField>&
) const ) const
@ -222,7 +222,7 @@ public:
//- Return the matrix diagonal coefficients corresponding to the //- Return the matrix diagonal coefficients corresponding to the
//- evaluation of the gradient of this patchField //- evaluation of the gradient of this patchField
tmp<Field<Type> > gradientInternalCoeffs() const tmp<Field<Type>> gradientInternalCoeffs() const
{ {
return tmp<Field<Type>> return tmp<Field<Type>>
( (
@ -232,7 +232,7 @@ public:
//- Return the matrix source coefficients corresponding to the //- Return the matrix source coefficients corresponding to the
//- evaluation of the gradient of this patchField //- evaluation of the gradient of this patchField
tmp<Field<Type> > gradientBoundaryCoeffs() const tmp<Field<Type>> gradientBoundaryCoeffs() const
{ {
return tmp<Field<Type>> return tmp<Field<Type>>
( (