diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C index f3e7c2dfc7..2a69f8c055 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C @@ -419,7 +419,7 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets) nInterProcPatches += curSubPatchIDs[procPatchi].size(); } - PtrList procPatches + polyPatchList procPatches ( curPatchSizes.size() + nInterProcPatches ); diff --git a/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructorFields.C b/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructorFields.C index adc881f21a..9301333276 100644 --- a/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructorFields.C +++ b/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructorFields.C @@ -129,8 +129,7 @@ Foam::parFvFieldReconstructor::reconstructFvVolumeField PtrList> patchFields(fld.mesh().boundary().size()); - const typename GeometricField::Boundary& - bfld = fld.boundaryField(); + const auto& bfld = fld.boundaryField(); forAll(bfld, patchI) { @@ -293,8 +292,7 @@ Foam::parFvFieldReconstructor::reconstructFvSurfaceField PtrList> patchFields(fld.mesh().boundary().size()); - const typename GeometricField::Boundary& - bfld = fld.boundaryField(); + const auto& bfld = fld.boundaryField(); forAll(bfld, patchI) { diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/SlicedDimensionedField.H b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/SlicedDimensionedField.H new file mode 100644 index 0000000000..d9ad2fb5fc --- /dev/null +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/SlicedDimensionedField.H @@ -0,0 +1,101 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2022 OpenFOAM Foundation + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::SlicedDimensionedField + +Description + Specialisation of DimensionedField that holds a slice of a given + field so that it acts as a DimensionedField. + +\*---------------------------------------------------------------------------*/ + +#ifndef Foam_SlicedDimensionedField_H +#define Foam_SlicedDimensionedField_H + +#include "DimensionedField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class SlicedDimensionedField Declaration +\*---------------------------------------------------------------------------*/ + +template +class SlicedDimensionedField +: + public DimensionedField +{ +public: + + // Public Typedefs + + //- Type of mesh on which this SlicedDimensionedField is instantiated + typedef typename GeoMesh::Mesh Mesh; + + + // Constructors + + //- Construct from components and field to slice + SlicedDimensionedField + ( + const IOobject& io, + const Mesh& mesh, + const dimensionSet& ds, + const Field& iField + ) + : + DimensionedField(io, mesh, ds, Field()) + { + // Set internalField to the slice of the complete field + UList::shallowCopy + ( + SubList(iField, GeoMesh::size(mesh)) + ); + } + + + //- Destructor + ~SlicedDimensionedField() + { + // Set internalField to nullptr to avoid deletion of underlying field + UList::shallowCopy(UList()); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C index 87d48080c4..bc3b9ef186 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C @@ -5,8 +5,8 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2011-2017,2022 OpenFOAM Foundation + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,23 +26,29 @@ License \*---------------------------------------------------------------------------*/ -#include "emptyPolyPatch.H" +#include "GeometricBoundaryField.H" #include "globalMeshData.H" #include "cyclicPolyPatch.H" +#include "emptyPolyPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template class PatchField, class GeoMesh> -void Foam::GeometricField::Boundary::readField +void Foam::GeometricBoundaryField::readField ( const DimensionedField& field, const dictionary& dict ) { - DebugInFunction << nl; + ///if (GeometricFieldclear(); - this->setSize(bmesh_.size()); + this->resize(bmesh_.size()); label nUnset = this->size(); @@ -180,7 +186,7 @@ void Foam::GeometricField::Boundary::readField // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template class PatchField, class GeoMesh> -Foam::GeometricField::Boundary::Boundary +Foam::GeometricBoundaryField::GeometricBoundaryField ( const BoundaryMesh& bmesh ) @@ -191,7 +197,7 @@ Foam::GeometricField::Boundary::Boundary template class PatchField, class GeoMesh> -Foam::GeometricField::Boundary::Boundary +Foam::GeometricBoundaryField::GeometricBoundaryField ( const BoundaryMesh& bmesh, const DimensionedField& field, @@ -201,7 +207,10 @@ Foam::GeometricField::Boundary::Boundary FieldField(bmesh.size()), bmesh_(bmesh) { - DebugInFunction << nl; + ///if (GeometricField::Boundary::Boundary template class PatchField, class GeoMesh> -Foam::GeometricField::Boundary::Boundary +Foam::GeometricBoundaryField::GeometricBoundaryField ( const BoundaryMesh& bmesh, const DimensionedField& field, @@ -231,7 +240,10 @@ Foam::GeometricField::Boundary::Boundary FieldField(bmesh.size()), bmesh_(bmesh) { - DebugInFunction << nl; + ///if (GeometricField::Boundary::Boundary template class PatchField, class GeoMesh> -Foam::GeometricField::Boundary::Boundary +Foam::GeometricBoundaryField::GeometricBoundaryField ( const BoundaryMesh& bmesh, const DimensionedField& field, @@ -294,7 +306,10 @@ Foam::GeometricField::Boundary::Boundary FieldField(bmesh.size()), bmesh_(bmesh) { - DebugInFunction << nl; + ///if (GeometricField::Boundary::Boundary template class PatchField, class GeoMesh> -Foam::GeometricField::Boundary::Boundary +Foam::GeometricBoundaryField::GeometricBoundaryField ( const DimensionedField& field, - const typename GeometricField::Boundary& btf + const GeometricBoundaryField& btf ) : FieldField(btf.size()), bmesh_(btf.bmesh_) { - DebugInFunction << nl; + ///if (GeometricField::Boundary::Boundary template class PatchField, class GeoMesh> -Foam::GeometricField::Boundary::Boundary +Foam::GeometricBoundaryField::GeometricBoundaryField ( const DimensionedField& field, - const typename GeometricField::Boundary& btf, + const GeometricBoundaryField& btf, const labelList& patchIDs, const word& patchFieldType ) @@ -334,7 +352,10 @@ Foam::GeometricField::Boundary::Boundary FieldField(btf.size()), bmesh_(btf.bmesh_) { - DebugInFunction << nl; + ///if (GeometricField::Boundary::Boundary template class PatchField, class GeoMesh> -Foam::GeometricField::Boundary::Boundary +Foam::GeometricBoundaryField::GeometricBoundaryField ( - const typename GeometricField::Boundary& btf + const GeometricBoundaryField& btf ) : FieldField(btf), bmesh_(btf.bmesh_) { - DebugInFunction << nl; + ///if (GeometricField class PatchField, class GeoMesh> -Foam::GeometricField::Boundary::Boundary +Foam::GeometricBoundaryField::GeometricBoundaryField ( const BoundaryMesh& bmesh, const DimensionedField& field, @@ -391,9 +415,12 @@ Foam::GeometricField::Boundary::Boundary // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template class PatchField, class GeoMesh> -void Foam::GeometricField::Boundary::updateCoeffs() +void Foam::GeometricBoundaryField::updateCoeffs() { - DebugInFunction << nl; + ///if (GeometricField::Boundary::updateCoeffs() template class PatchField, class GeoMesh> -void Foam::GeometricField::Boundary::evaluate() +void Foam::GeometricBoundaryField::evaluate() { - DebugInFunction << nl; + ///if (GeometricField::Boundary::evaluate() template class PatchField, class GeoMesh> Foam::wordList -Foam::GeometricField::Boundary::types() const +Foam::GeometricBoundaryField::types() const { const FieldField& pff = *this; @@ -484,32 +514,30 @@ Foam::GeometricField::Boundary::types() const template class PatchField, class GeoMesh> -typename Foam::GeometricField::Boundary -Foam::GeometricField::Boundary:: +Foam::GeometricBoundaryField +Foam::GeometricBoundaryField:: boundaryInternalField() const { - typename GeometricField::Boundary - BoundaryInternalField(*this); + GeometricBoundaryField result(*this); - forAll(BoundaryInternalField, patchi) + forAll(result, patchi) { - BoundaryInternalField[patchi] == - this->operator[](patchi).patchInternalField(); + result[patchi] == this->operator[](patchi).patchInternalField(); } - return BoundaryInternalField; + return result; } template class PatchField, class GeoMesh> Foam::LduInterfaceFieldPtrsList -Foam::GeometricField::Boundary::interfaces() const +Foam::GeometricBoundaryField::interfaces() const { LduInterfaceFieldPtrsList list(this->size()); forAll(list, patchi) { - const LduInterfaceField* lduPtr = + const auto* lduPtr = isA>(this->operator[](patchi)); if (lduPtr) @@ -524,14 +552,14 @@ Foam::GeometricField::Boundary::interfaces() const template class PatchField, class GeoMesh> Foam::lduInterfaceFieldPtrsList -Foam::GeometricField::Boundary:: +Foam::GeometricBoundaryField:: scalarInterfaces() const { lduInterfaceFieldPtrsList list(this->size()); forAll(list, patchi) { - const lduInterfaceField* lduPtr = + const auto* lduPtr = isA(this->operator[](patchi)); if (lduPtr) @@ -545,7 +573,7 @@ scalarInterfaces() const template class PatchField, class GeoMesh> -void Foam::GeometricField::Boundary::writeEntry +void Foam::GeometricBoundaryField::writeEntry ( const word& keyword, Ostream& os @@ -560,7 +588,7 @@ void Foam::GeometricField::Boundary::writeEntry template class PatchField, class GeoMesh> -void Foam::GeometricField::Boundary::writeEntries +void Foam::GeometricBoundaryField::writeEntries ( Ostream& os ) const @@ -577,10 +605,9 @@ void Foam::GeometricField::Boundary::writeEntries // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template class PatchField, class GeoMesh> -void Foam::GeometricField::Boundary::operator= +void Foam::GeometricBoundaryField::operator= ( - const typename GeometricField:: - Boundary& bf + const GeometricBoundaryField& bf ) { FieldField::operator=(bf); @@ -588,30 +615,29 @@ void Foam::GeometricField::Boundary::operator= template class PatchField, class GeoMesh> -void Foam::GeometricField::Boundary::operator= +void Foam::GeometricBoundaryField::operator= ( - const FieldField& ptff + const FieldField& bf ) { - FieldField::operator=(ptff); + FieldField::operator=(bf); } template class PatchField, class GeoMesh> -void Foam::GeometricField::Boundary::operator= +void Foam::GeometricBoundaryField::operator= ( - const Type& t + const Type& val ) { - FieldField::operator=(t); + FieldField::operator=(val); } template class PatchField, class GeoMesh> -void Foam::GeometricField::Boundary::operator== +void Foam::GeometricBoundaryField::operator== ( - const typename GeometricField:: - Boundary& bf + const GeometricBoundaryField& bf ) { forAll(*this, patchi) @@ -622,27 +648,27 @@ void Foam::GeometricField::Boundary::operator== template class PatchField, class GeoMesh> -void Foam::GeometricField::Boundary::operator== +void Foam::GeometricBoundaryField::operator== ( - const FieldField& ptff + const FieldField& bf ) { forAll(*this, patchi) { - this->operator[](patchi) == ptff[patchi]; + this->operator[](patchi) == bf[patchi]; } } template class PatchField, class GeoMesh> -void Foam::GeometricField::Boundary::operator== +void Foam::GeometricBoundaryField::operator== ( - const Type& t + const Type& val ) { forAll(*this, patchi) { - this->operator[](patchi) == t; + this->operator[](patchi) == val; } } @@ -653,8 +679,7 @@ template class PatchField, class GeoMesh> Foam::Ostream& Foam::operator<< ( Ostream& os, - const typename GeometricField:: - Boundary& bf + const GeometricBoundaryField& bf ) { os << static_cast&>(bf); diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.H new file mode 100644 index 0000000000..c484a500c8 --- /dev/null +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.H @@ -0,0 +1,238 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2011-2017,2022 OpenFOAM Foundation + Copyright (C) 2015-2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::GeometricBoundaryField + +Description + Generic GeometricBoundaryField class. + +SourceFiles + GeometricBoundaryField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Foam_GeometricBoundaryField_H +#define Foam_GeometricBoundaryField_H + +#include "dimensionedTypes.H" +#include "DimensionedField.H" +#include "FieldField.H" +#include "lduInterfaceFieldPtrsList.H" +#include "LduInterfaceFieldPtrsList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward Declarations +class dictionary; + +template class PatchField, class GeoMesh> +class GeometricField; + +/*---------------------------------------------------------------------------*\ + Class GeometricBoundaryField Declaration +\*---------------------------------------------------------------------------*/ + +template class PatchField, class GeoMesh> +class GeometricBoundaryField +: + public FieldField +{ +public: + + // Public Typedefs + + //- The boundary mesh type for the boundary fields + typedef typename GeoMesh::BoundaryMesh BoundaryMesh; + + //- The internal field type associated with the boundary fields + typedef DimensionedField Internal; + + //- The patch field type for the boundary fields + typedef PatchField Patch; + + +private: + + // Private Data + + //- Reference to BoundaryMesh for which this field is defined + const BoundaryMesh& bmesh_; + + +public: + + // Constructors + + //- Construct from a BoundaryMesh, setting patches later + explicit GeometricBoundaryField(const BoundaryMesh& bmesh); + + //- Construct from a BoundaryMesh, reference to the internal field + //- and a patch type + GeometricBoundaryField + ( + const BoundaryMesh& bmesh, + const DimensionedField& field, + const word& patchFieldType = PatchField::calculatedType() + ); + + //- Construct from a BoundaryMesh, reference to the internal field + //- and a wordList of patch types and optional the actual patch + //- types (to override constraint patches) + GeometricBoundaryField + ( + const BoundaryMesh& bmesh, + const DimensionedField& field, + const wordList& wantedPatchTypes, + const wordList& actualPatchTypes = wordList() + ); + + //- Construct from a BoundaryMesh, reference to the internal field + //- and a PtrList> + GeometricBoundaryField + ( + const BoundaryMesh& bmesh, + const DimensionedField& field, + const PtrList>& + ); + + //- Construct as copy setting the reference to the internal field + GeometricBoundaryField + ( + const DimensionedField& field, + const GeometricBoundaryField& btf + ); + + //- Construct as copy setting the reference to the internal field + //- and resetting type of field for given patch IDs + GeometricBoundaryField + ( + const DimensionedField& field, + const GeometricBoundaryField& btf, + const labelList& patchIDs, + const word& patchFieldName + ); + + //- Copy construct + // Dangerous because Field may be set to a field which gets deleted + // Need new type of BoundaryField, one which is part of a geometric + // field for which snGrad etc. may be called and a free standing + // BoundaryField for which such operations are unavailable. + GeometricBoundaryField(const GeometricBoundaryField& btf); + + //- Construct from dictionary + GeometricBoundaryField + ( + const BoundaryMesh& bmesh, + const DimensionedField& field, + const dictionary& dict + ); + + + // Member Functions + + //- Read the boundary field + void readField + ( + const DimensionedField& field, + const dictionary& dict + ); + + //- Update the boundary condition coefficients + void updateCoeffs(); + + //- Evaluate boundary conditions + void evaluate(); + + //- Return a list of the patch types + wordList types() const; + + //- Return boundary field of cell values neighbouring the boundary + GeometricBoundaryField boundaryInternalField() const; + + //- Return a list of pointers for each patch field with only those + //- pointing to interfaces being set + LduInterfaceFieldPtrsList interfaces() const; + + //- Return a list of pointers for each patch field with only those + //- pointing to interfaces being set + lduInterfaceFieldPtrsList scalarInterfaces() const; + + //- Write boundary field as dictionary entry + void writeEntry(const word& keyword, Ostream& os) const; + + //- Write dictionary entries of the individual boundary fields. + void writeEntries(Ostream& os) const; + + + // Member Operators + + //- Copy assignment from GeometricBoundaryField + void operator=(const GeometricBoundaryField& bf); + + //- Copy assignment from FieldField\ + void operator=(const FieldField& bf); + + //- Assignment to uniform value + void operator=(const Type& val); + + //- Forced assignment from GeometricBoundaryField + void operator==(const GeometricBoundaryField& bf); + + //- Forced assignment from FieldField\ + void operator==(const FieldField& bf); + + //- Forced assignment to uniform value + void operator==(const Type& val); +}; + + +template class PatchField, class GeoMesh> +Ostream& operator<< +( + Ostream&, + const GeometricBoundaryField& +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "GeometricBoundaryField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index 4afcb9659c..1532c6fffd 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -1372,7 +1372,6 @@ Foam::Ostream& Foam::operator<< // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "GeometricFieldNew.C" -#include "GeometricBoundaryField.C" #include "GeometricFieldFunctions.C" // ************************************************************************* // diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H index 78cfc3e572..24401b338d 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H @@ -33,21 +33,16 @@ Description SourceFiles GeometricFieldI.H GeometricField.C - GeometricBoundaryField.C GeometricFieldFunctions.H GeometricFieldFunctions.C \*---------------------------------------------------------------------------*/ -#ifndef GeometricField_H -#define GeometricField_H +#ifndef Foam_GeometricField_H +#define Foam_GeometricField_H #include "regIOobject.H" -#include "dimensionedTypes.H" -#include "DimensionedField.H" -#include "FieldField.H" -#include "lduInterfaceFieldPtrsList.H" -#include "LduInterfaceFieldPtrsList.H" +#include "GeometricBoundaryField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -84,178 +79,32 @@ class GeometricField : public DimensionedField { - // Private Member Functions - - //- Read from file if it is present - bool readIfPresent(); - - //- Read old time field from file if it is present - bool readOldTimeIfPresent(); - - public: // Public Typedefs - //- Type of mesh on which this GeometricField is instantiated + //- The mesh type for the GeometricField typedef typename GeoMesh::Mesh Mesh; - //- Type of boundary mesh on which this GeometricField::Boundary is - //- instantiated + //- The boundary mesh type for the boundary fields typedef typename GeoMesh::BoundaryMesh BoundaryMesh; - //- Type of the internal field from which this GeometricField is derived + //- The internal field type from which this GeometricField is derived typedef DimensionedField Internal; - //- Type of the patch field of which the GeometricField::Boundary is - //- composed + //- Type of boundary fields + typedef GeometricBoundaryField Boundary; + + //- The patch field type for the GeometricBoundaryField typedef PatchField Patch; - - //- The boundary fields - class Boundary - : - public FieldField - { - // Private Data - - //- Reference to BoundaryMesh for which this field is defined - const BoundaryMesh& bmesh_; - - - public: - - // Constructors - - //- Construct from a BoundaryMesh, setting patches later - explicit Boundary(const BoundaryMesh& bmesh); - - //- Construct from a BoundaryMesh, reference to the internal field - //- and a patch type - Boundary - ( - const BoundaryMesh& bmesh, - const Internal& field, - const word& patchFieldType = PatchField::calculatedType() - ); - - //- Construct from a BoundaryMesh, reference to the internal field - //- and a wordList of patch types and optional the actual patch - //- types (to override constraint patches) - Boundary - ( - const BoundaryMesh& bmesh, - const Internal& field, - const wordList& wantedPatchTypes, - const wordList& actualPatchTypes = wordList() - ); - - //- Construct from a BoundaryMesh, reference to the internal field - //- and a PtrList> - Boundary - ( - const BoundaryMesh& bmesh, - const Internal& field, - const PtrList>& - ); - - //- Construct as copy setting the reference to the internal field - Boundary - ( - const Internal& field, - const Boundary& btf - ); - - //- Construct as copy setting the reference to the internal field - //- and resetting type of field for given patch IDs - Boundary - ( - const Internal& field, - const Boundary& btf, - const labelList& patchIDs, - const word& patchFieldName - ); - - //- Copy construct - // Dangerous because Field may be set to a field which gets deleted - // Need new type of BoundaryField, one which is part of a geometric - // field for which snGrad etc. may be called and a free standing - // BoundaryField for which such operations are unavailable. - Boundary(const Boundary& btf); - - //- Construct from dictionary - Boundary - ( - const BoundaryMesh& bmesh, - const Internal& field, - const dictionary& dict - ); - - - // Member Functions - - //- Read the boundary field - void readField - ( - const Internal& field, - const dictionary& dict - ); - - //- Update the boundary condition coefficients - void updateCoeffs(); - - //- Evaluate boundary conditions - void evaluate(); - - //- Return a list of the patch types - wordList types() const; - - //- Return BoundaryField of the cell values neighbouring - //- the boundary - Boundary boundaryInternalField() const; - - //- Return a list of pointers for each patch field with only those - //- pointing to interfaces being set - LduInterfaceFieldPtrsList interfaces() const; - - //- Return a list of pointers for each patch field with only those - //- pointing to interfaces being set - lduInterfaceFieldPtrsList scalarInterfaces() const; - - //- Write boundary field as dictionary entry - void writeEntry(const word& keyword, Ostream& os) const; - - //- Write dictionary entries of the individual boundary fields. - void writeEntries(Ostream& os) const; - - - // Member Operators - - //- Assignment to BoundaryField - void operator=(const Boundary&); - - //- Assignment to FieldField - void operator=(const FieldField&); - - //- Assignment to Type - void operator=(const Type&); - - - //- Forced assignment to - // BoundaryField - void operator==(const Boundary&); - - //- Forced assignment to FieldField - void operator==(const FieldField&); - - //- Forced assignment to Type - void operator==(const Type&); - }; + //- The field component type + typedef typename Field::cmptType cmptType; private: - // Private data + // Private Data //- Current time index. // Used to trigger the storing of the old-time value @@ -267,12 +116,18 @@ private: //- Pointer to previous iteration (used for under-relaxation) mutable GeometricField* fieldPrevIterPtr_; - //- Boundary Type field containing boundary field values + //- Boundary field containing boundary field values Boundary boundaryField_; // Private Member Functions + //- Read from file if it is present + bool readIfPresent(); + + //- Read old time field from file if it is present + bool readOldTimeIfPresent(); + //- Read the field from the dictionary void readFields(const dictionary& dict); @@ -286,10 +141,6 @@ public: TypeName("GeometricField"); - // Public typedefs - - typedef typename Field::cmptType cmptType; - // Static Member Functions //- Return a null geometric field diff --git a/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.C b/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.C index b3adafac95..5b552e009b 100644 --- a/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -47,11 +48,8 @@ slicedBoundaryField const bool preserveProcessorOnly ) { - tmp> tbf - ( - new FieldField(mesh.boundary().size()) - ); - FieldField& bf = tbf.ref(); + auto tbf = tmp>::New(mesh.boundary().size()); + auto& bf = tbf.ref(); forAll(mesh.boundary(), patchi) { @@ -123,11 +121,8 @@ slicedBoundaryField const bool preserveCouples ) { - tmp> tbf - ( - new FieldField(mesh.boundary().size()) - ); - FieldField& bf = tbf.ref(); + auto tbf = tmp>::New(mesh.boundary().size()); + auto& bf = tbf.ref(); forAll(mesh.boundary(), patchi) { @@ -157,10 +152,10 @@ slicedBoundaryField new SlicedPatchField ( mesh.boundary()[patchi], - DimensionedField::null() + DimensionedField::null(), + bField[patchi] ) ); - bf[patchi].UList::shallowCopy(bField[patchi]); } } @@ -170,38 +165,6 @@ slicedBoundaryField // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -< - class Type, - template class PatchField, - template class SlicedPatchField, - class GeoMesh -> -Foam::SlicedGeometricField:: -Internal::Internal -( - const IOobject& io, - const Mesh& mesh, - const dimensionSet& ds, - const Field& iField -) -: - DimensionedField - ( - io, - mesh, - ds, - Field() - ) -{ - // Set the internalField to the slice of the complete field - UList::shallowCopy - ( - typename Field::subField(iField, GeoMesh::size(mesh)) - ); -} - - template < class Type, @@ -228,10 +191,10 @@ SlicedGeometricField slicedBoundaryField(mesh, completeField, preserveCouples) ) { - // Set the internalField to the slice of the complete field + // Set internalField to the slice of the complete field UList::shallowCopy ( - typename Field::subField(completeField, GeoMesh::size(mesh)) + SubList(completeField, GeoMesh::size(mesh)) ); correctBoundaryConditions(); @@ -272,10 +235,10 @@ SlicedGeometricField ) ) { - // Set the internalField to the slice of the complete field + // Set internalField to the slice of the complete field UList::shallowCopy ( - typename Field::subField(completeIField, GeoMesh::size(mesh)) + SubList(completeIField, GeoMesh::size(mesh)) ); correctBoundaryConditions(); @@ -306,7 +269,7 @@ SlicedGeometricField slicedBoundaryField(gf.mesh(), gf.boundaryField(), preserveCouples) ) { - // Set the internalField to the supplied internal field + // Set internalField to the internal field UList::shallowCopy(gf.primitiveField()); correctBoundaryConditions(); @@ -335,7 +298,7 @@ SlicedGeometricField slicedBoundaryField(gf.mesh(), gf.boundaryField(), true) ) { - // Set the internalField to the supplied internal field + // Set internalField to the internal field UList::shallowCopy(gf.primitiveField()); } @@ -357,12 +320,9 @@ clone() const return tmp < SlicedGeometricField - > + >::New ( - new SlicedGeometricField - ( - *this - ) + *this ); } @@ -379,25 +339,8 @@ template Foam::SlicedGeometricField:: ~SlicedGeometricField() { - // Set the internalField storage pointer to nullptr before its destruction - // to protect the field it a slice of. - UList::shallowCopy(UList(nullptr, 0)); -} - - -template -< - class Type, - template class PatchField, - template class SlicedPatchField, - class GeoMesh -> -Foam::SlicedGeometricField:: -Internal::~Internal() -{ - // Set the internalField storage pointer to nullptr before its destruction - // to protect the field it a slice of. - UList::shallowCopy(UList(nullptr, 0)); + // Set internalField to nullptr to avoid deletion of underlying field + UList::shallowCopy(UList()); } diff --git a/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.H b/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.H index ea65b539ca..85448c2c7b 100644 --- a/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2011-2017,2022 OpenFOAM Foundation ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,10 +42,11 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef SlicedGeometricField_H -#define SlicedGeometricField_H +#ifndef Foam_SlicedGeometricField_H +#define Foam_SlicedGeometricField_H #include "GeometricField.H" +#include "SlicedDimensionedField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -69,10 +70,13 @@ class SlicedGeometricField { public: - typedef typename GeoMesh::Mesh Mesh; - typedef typename GeoMesh::BoundaryMesh BoundaryMesh; + // Public Typedefs - class Internal; + typedef typename GeoMesh::Mesh Mesh; + typedef typename GeoMesh::BoundaryMesh BoundaryMesh; + + //- The internal field slice for this SlicedGeometricField + typedef SlicedDimensionedField Internal; private: @@ -81,7 +85,8 @@ private: //- Slice the given field and a create a PtrList of SlicedPatchField // from which the boundary field is built - tmp> slicedBoundaryField + tmp> + slicedBoundaryField ( const Mesh& mesh, const Field& completeField, @@ -91,7 +96,8 @@ private: //- Slice the given field and a create a PtrList of SlicedPatchField // from which the boundary field is built - tmp> slicedBoundaryField + tmp> + slicedBoundaryField ( const Mesh& mesh, const FieldField& bField, @@ -133,7 +139,7 @@ public: ); //- Construct from components and separate fields to slice for the - // internal field and boundary field + //- internal field and boundary field SlicedGeometricField ( const IOobject&, @@ -146,7 +152,7 @@ public: ); //- Construct from GeometricField. Reuses full internal and - // patch fields except on couples (preserveCouples=true). + //- patch fields except on couples (preserveCouples=true). SlicedGeometricField ( const IOobject&, @@ -154,7 +160,7 @@ public: const bool preserveCouples=true ); - //- Construct as copy + //- Copy construct SlicedGeometricField ( const SlicedGeometricField @@ -168,57 +174,20 @@ public: //- Clone tmp> - clone() const; + clone() const; //- Destructor ~SlicedGeometricField(); - // Member functions + // Member Functions //- Correct boundary field void correctBoundaryConditions(); }; -/*---------------------------------------------------------------------------*\ - Class SlicedGeometricField::Internal Declaration -\*---------------------------------------------------------------------------*/ - -//- The internalField of a SlicedGeometricField -template -< - class Type, - template class PatchField, - template class SlicedPatchField, - class GeoMesh -> -class SlicedGeometricField:: -Internal -: - public GeometricField::Internal -{ - -public: - - // Constructors - - //- Construct from components and field to slice - Internal - ( - const IOobject&, - const Mesh&, - const dimensionSet&, - const Field& iField - ); - - - //- Destructor - ~Internal(); -}; - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/fields/GeometricFields/pointFields/pointFieldsFwd.H b/src/OpenFOAM/fields/GeometricFields/pointFields/pointFieldsFwd.H index a4d245562a..7384c3c540 100644 --- a/src/OpenFOAM/fields/GeometricFields/pointFields/pointFieldsFwd.H +++ b/src/OpenFOAM/fields/GeometricFields/pointFields/pointFieldsFwd.H @@ -45,7 +45,14 @@ SourceFiles namespace Foam { +// Geometric internal field template class DimensionedField; + +// Geometric boundary field +template class PatchField, class GeoMesh> +class GeometricBoundaryField; + +// Geometric field (internal + boundary) template class PatchField, class GeoMesh> class GeometricField; @@ -61,6 +68,11 @@ template class pointPatchField; template using PointField = GeometricField; +//- A point boundary field for a given Type +template +using PointBoundaryField = + GeometricBoundaryField; + //- A point internal field for a given type template using PointInternalField = DimensionedField; diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceField.H b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceField.H index 404a5a34a5..47ae10ba2b 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceField.H +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,8 +36,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef LduInterfaceField_H -#define LduInterfaceField_H +#ifndef Foam_LduInterfaceField_H +#define Foam_LduInterfaceField_H #include "lduInterfaceField.H" #include "primitiveFieldsFwd.H" @@ -48,8 +48,9 @@ SourceFiles namespace Foam { -// Forward declarations +// Forward Declarations class lduMatrix; +template class LduInterfaceField; /*---------------------------------------------------------------------------*\ Class LduInterfaceField Declaration diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceFieldPtrsList.H b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceFieldPtrsList.H index 6f8158125a..d24acc573c 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceFieldPtrsList.H +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceFieldPtrsList.H @@ -24,15 +24,15 @@ License along with OpenFOAM. If not, see . Type - lduInterfaceFieldPtrsList + LduInterfaceFieldPtrsList Description List of coupled interface fields to be used in coupling. \*---------------------------------------------------------------------------*/ -#ifndef LduInterfaceFieldPtrsList_H -#define LduInterfaceFieldPtrsList_H +#ifndef Foam_LduInterfaceFieldPtrsList_H +#define Foam_LduInterfaceFieldPtrsList_H #include "LduInterfaceField.H" #include "UPtrList.H" @@ -42,25 +42,9 @@ Description namespace Foam { -/*---------------------------------------------------------------------------*\ - Class LduInterfaceFieldPtrsList Declaration -\*---------------------------------------------------------------------------*/ - +//- Store lists of LduInterfaceField as a UPtrList template -class LduInterfaceFieldPtrsList -: - public UPtrList> -{ -public: - - LduInterfaceFieldPtrsList(label size) - : - UPtrList>(size) - {} -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +using LduInterfaceFieldPtrsList = UPtrList>; } // End namespace Foam diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrix.H b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrix.H index f5f332d841..6ed2091a77 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrix.H +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrix.H @@ -50,8 +50,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef LduMatrix_H -#define LduMatrix_H +#ifndef Foam_LduMatrix_H +#define Foam_LduMatrix_H #include "lduMesh.H" #include "Field.H" diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixATmul.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixATmul.C index e90e5c064b..9ae8571e86 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixATmul.C +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixATmul.C @@ -27,7 +27,6 @@ License \*---------------------------------------------------------------------------*/ #include "LduMatrix.H" -#include "LduInterfaceFieldPtrsList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduInterface.H b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduInterface.H index 25ea7c1dae..872cb383b1 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduInterface.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduInterface.H @@ -36,8 +36,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef lduInterface_H -#define lduInterface_H +#ifndef Foam_lduInterface_H +#define Foam_lduInterface_H #include "labelField.H" #include "typeInfo.H" @@ -48,8 +48,11 @@ SourceFiles namespace Foam { +// Forward Declarations +class lduInterface; + /*---------------------------------------------------------------------------*\ - Class lduInterface Declaration + Class lduInterface Declaration \*---------------------------------------------------------------------------*/ class lduInterface diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduInterfacePtrsList.H b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduInterfacePtrsList.H index f436a5b948..1baff716e1 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduInterfacePtrsList.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduInterfacePtrsList.H @@ -31,8 +31,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef lduInterfacePtrsList_H -#define lduInterfacePtrsList_H +#ifndef Foam_lduInterfacePtrsList_H +#define Foam_lduInterfacePtrsList_H #include "lduInterface.H" #include "UPtrList.H" @@ -41,8 +41,11 @@ Description namespace Foam { - typedef UPtrList lduInterfacePtrsList; -} + +//- Store lists of lduInterface as a UPtrList +typedef UPtrList lduInterfacePtrsList; + +} // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.H b/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.H index 969f46e480..45018ac11a 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.H +++ b/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.H @@ -35,10 +35,10 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef pointBoundaryMesh_H -#define pointBoundaryMesh_H +#ifndef Foam_pointBoundaryMesh_H +#define Foam_pointBoundaryMesh_H -#include "pointPatchList.H" +#include "pointPatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H index 933e4ad1d6..fdd5fb42d5 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H @@ -35,12 +35,13 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef pointPatch_H -#define pointPatch_H +#ifndef Foam_pointPatch_H +#define Foam_pointPatch_H #include "labelList.H" #include "vectorField.H" #include "pointField.H" +#include "PtrList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -50,8 +51,12 @@ namespace Foam // Forward Declarations class pointBoundaryMesh; class pointConstraint; +class pointPatch; class PstreamBuffers; +//- Store lists of pointPatch as a PtrList +typedef PtrList pointPatchList; + /*---------------------------------------------------------------------------*\ Class pointPatch Declaration \*---------------------------------------------------------------------------*/ diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatchList.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatchList.H index 3eb0709c3e..67998f3d46 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatchList.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatchList.H @@ -1,57 +1,9 @@ /*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011 OpenFOAM Foundation -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Typedef - Foam::pointPatchList - Description - container classes for pointPatch + Compatibility include (MAR-2022) \*---------------------------------------------------------------------------*/ -#ifndef pointPatchList_H -#define pointPatchList_H - #include "pointPatch.H" -#include "PtrList.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -typedef PtrList pointPatchList; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H index ebc6b1ea51..f2d6fa0112 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H @@ -39,8 +39,8 @@ SourceFiles #ifndef Foam_polyBoundaryMesh_H #define Foam_polyBoundaryMesh_H -#include "polyPatchList.H" #include "regIOobject.H" +#include "polyPatch.H" #include "labelPair.H" #include "HashSet.H" @@ -56,7 +56,6 @@ class wordRes; Ostream& operator<<(Ostream& os, const polyBoundaryMesh& pbm); - /*---------------------------------------------------------------------------*\ Class polyBoundaryMesh Declaration \*---------------------------------------------------------------------------*/ diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index f0ec4d2c97..e5dd771dcf 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -959,7 +959,7 @@ Foam::polyMesh::cellTree() const void Foam::polyMesh::addPatches ( - PtrList& plist, + polyPatchList& plist, const bool validBoundary ) { @@ -1060,7 +1060,7 @@ void Foam::polyMesh::addPatches ) { // Acquire ownership of the pointers - PtrList plist(const_cast&>(p)); + polyPatchList plist(const_cast&>(p)); addPatches(plist, validBoundary); } diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H index cedcb558d3..4a631d55a7 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H @@ -583,7 +583,7 @@ public: //- Add boundary patches void addPatches ( - PtrList& plist, + polyPatchList& plist, const bool validBoundary = true ); diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H index 2dc4b2c00d..bccfc2f78c 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H @@ -39,14 +39,15 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef polyPatch_H -#define polyPatch_H +#ifndef Foam_polyPatch_H +#define Foam_polyPatch_H #include "patchIdentifier.H" #include "primitivePatch.H" #include "typeInfo.H" #include "runTimeSelectionTables.H" #include "SubField.H" +#include "PtrList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,8 +60,10 @@ class polyPatch; class polyTopoChange; class PstreamBuffers; -Ostream& operator<<(Ostream&, const polyPatch&); +//- Store lists of polyPatch as a PtrList +typedef PtrList polyPatchList; +Ostream& operator<<(Ostream&, const polyPatch&); /*---------------------------------------------------------------------------*\ Class polyPatch Declaration diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatchList.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatchList.H index 27521b2527..d0208af7af 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatchList.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatchList.H @@ -1,57 +1,9 @@ /*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011 OpenFOAM Foundation -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Typedef - Foam::polyPatchList - Description - container classes for polyPatch + Compatibility include (MAR-2022) \*---------------------------------------------------------------------------*/ -#ifndef polyPatchList_H -#define polyPatchList_H - #include "polyPatch.H" -#include "PtrList.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -typedef PtrList polyPatchList; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif // ************************************************************************* // diff --git a/src/dynamicMesh/boundaryMesh/boundaryMesh.H b/src/dynamicMesh/boundaryMesh/boundaryMesh.H index 2e30f20c31..9540d59af6 100644 --- a/src/dynamicMesh/boundaryMesh/boundaryMesh.H +++ b/src/dynamicMesh/boundaryMesh/boundaryMesh.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,15 +36,15 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef boundaryMesh_H -#define boundaryMesh_H +#ifndef Foam_boundaryMesh_H +#define Foam_boundaryMesh_H #include "bMesh.H" #include "boundaryPatch.H" +#include "className.H" +#include "polyPatch.H" #include "PrimitivePatch.H" #include "PtrList.H" -#include "polyPatchList.H" -#include "className.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/dynamicMesh/boundaryPatch/boundaryPatch.H b/src/dynamicMesh/boundaryPatch/boundaryPatch.H index ec7d66a081..8c4ce07ebb 100644 --- a/src/dynamicMesh/boundaryPatch/boundaryPatch.H +++ b/src/dynamicMesh/boundaryPatch/boundaryPatch.H @@ -37,8 +37,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef boundaryPatch_H -#define boundaryPatch_H +#ifndef Foam_boundaryPatch_H +#define Foam_boundaryPatch_H #include "patchIdentifier.H" #include "autoPtr.H" diff --git a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H index a78994aa82..fb1b7e4d08 100644 --- a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H +++ b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H @@ -42,7 +42,7 @@ Author #ifndef Foam_faBoundaryMesh_H #define Foam_faBoundaryMesh_H -#include "faPatchList.H" +#include "faPatch.H" #include "lduInterfacePtrsList.H" #include "wordList.H" #include "pointField.H" diff --git a/src/finiteArea/faMesh/faGlobalMeshData/faProcessorTopology.H b/src/finiteArea/faMesh/faGlobalMeshData/faProcessorTopology.H index d79760b83c..607ff448f5 100644 --- a/src/finiteArea/faMesh/faGlobalMeshData/faProcessorTopology.H +++ b/src/finiteArea/faMesh/faGlobalMeshData/faProcessorTopology.H @@ -34,11 +34,10 @@ Author \*---------------------------------------------------------------------------*/ -#ifndef faProcessorTopology_H -#define faProcessorTopology_H +#ifndef Foam_faProcessorTopology_H +#define Foam_faProcessorTopology_H #include "ProcessorTopology.H" -#include "faPatchList.H" #include "processorFaPatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteArea/faMesh/faMesh.C b/src/finiteArea/faMesh/faMesh.C index a98c49060d..206a33ddb6 100644 --- a/src/finiteArea/faMesh/faMesh.C +++ b/src/finiteArea/faMesh/faMesh.C @@ -438,7 +438,7 @@ Foam::faMesh::faMesh(const polyPatch& pp) DebugInFunction << "Creating from polyPatch:" << pp.name() << endl; // Add single faPatch "default", but with processor connections - PtrList newPatches + faPatchList newPatches ( createOnePatch("default") ); @@ -479,7 +479,7 @@ Foam::faMesh::faMesh { DebugInFunction << "Creating from definition (dictionary)" << endl; - PtrList newPatches + faPatchList newPatches ( createPatchList ( diff --git a/src/finiteArea/faMesh/faMesh.H b/src/finiteArea/faMesh/faMesh.H index 731a2c8208..d787074343 100644 --- a/src/finiteArea/faMesh/faMesh.H +++ b/src/finiteArea/faMesh/faMesh.H @@ -414,14 +414,14 @@ class faMesh // Helpers //- Create a single patch - PtrList createOnePatch + faPatchList createOnePatch ( const word& patchName, const word& patchType = "" ) const; //- Create list of patches from boundary definition - PtrList createPatchList + faPatchList createPatchList ( const dictionary& bndDict, const word& emptyPatchName = "", @@ -526,7 +526,7 @@ public: //- Add boundary patches. Constructor helper void addFaPatches ( - PtrList& plist, + faPatchList& plist, const bool validBoundary = true ); diff --git a/src/finiteArea/faMesh/faMeshPatches.C b/src/finiteArea/faMesh/faMeshPatches.C index 42d8d99d6a..5cf1cc66ac 100644 --- a/src/finiteArea/faMesh/faMeshPatches.C +++ b/src/finiteArea/faMesh/faMeshPatches.C @@ -36,7 +36,7 @@ License void Foam::faMesh::addFaPatches ( - PtrList& plist, + faPatchList& plist, const bool validBoundary ) { @@ -67,13 +67,13 @@ void Foam::faMesh::addFaPatches ) { // Acquire ownership of the pointers - PtrList plist(const_cast&>(p)); + faPatchList plist(const_cast&>(p)); addFaPatches(plist, validBoundary); } -Foam::PtrList Foam::faMesh::createOnePatch +Foam::faPatchList Foam::faMesh::createOnePatch ( const word& patchName, const word& patchType @@ -98,7 +98,7 @@ Foam::PtrList Foam::faMesh::createOnePatch } -Foam::PtrList Foam::faMesh::createPatchList +Foam::faPatchList Foam::faMesh::createPatchList ( const dictionary& bndDict, const word& emptyPatchName, @@ -495,7 +495,7 @@ Foam::PtrList Foam::faMesh::createPatchList // Now convert list of definitions to list of patches label nPatches = 0; - PtrList newPatches(faPatchDefs.size()); + faPatchList newPatches(faPatchDefs.size()); for (faPatchData& patchDef : faPatchDefs) { diff --git a/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H b/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H index 2090cbe650..35d19bd11c 100644 --- a/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H +++ b/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H @@ -49,6 +49,7 @@ SourceFiles #include "labelList.H" #include "pointField.H" #include "typeInfo.H" +#include "PtrList.H" #include "faPatchFieldsFwd.H" #include "autoPtr.H" #include "runTimeSelectionTables.H" @@ -61,6 +62,10 @@ namespace Foam // Forward Declarations class faBoundaryMesh; class faPatch; + +//- Store lists of faPatch as a PtrList +typedef PtrList faPatchList; + Ostream& operator<<(Ostream&, const faPatch&); /*---------------------------------------------------------------------------*\ diff --git a/src/finiteArea/faMesh/faPatches/faPatch/faPatchList.H b/src/finiteArea/faMesh/faPatches/faPatch/faPatchList.H index 784280f3a8..d531d2abcd 100644 --- a/src/finiteArea/faMesh/faPatches/faPatch/faPatchList.H +++ b/src/finiteArea/faMesh/faPatches/faPatch/faPatchList.H @@ -1,57 +1,9 @@ /*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2016-2017 Wikki Ltd -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Typedef - foam::faPatchList - Description - Container classes for faPatch + Compatibility include (MAR-2022) \*---------------------------------------------------------------------------*/ -#ifndef faPatchList_H -#define faPatchList_H - #include "faPatch.H" -#include "PtrList.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -typedef PtrList faPatchList; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif // ************************************************************************* // diff --git a/src/finiteArea/fields/areaFields/areaFieldsFwd.H b/src/finiteArea/fields/areaFields/areaFieldsFwd.H index c807f4c4f5..621222c69b 100644 --- a/src/finiteArea/fields/areaFields/areaFieldsFwd.H +++ b/src/finiteArea/fields/areaFields/areaFieldsFwd.H @@ -42,7 +42,14 @@ SourceFiles namespace Foam { +// Geometric internal field template class DimensionedField; + +// Geometric boundary field +template class PatchField, class GeoMesh> +class GeometricBoundaryField; + +// Geometric field (internal + boundary) template class PatchField, class GeoMesh> class GeometricField; @@ -57,6 +64,10 @@ template class faPatchField; template using AreaField = GeometricField; +//- An area boundary field for a given Type +template +using AreaBoundaryField = GeometricBoundaryField; + //- An area internal field for a given type template using AreaInternalField = DimensionedField; diff --git a/src/finiteArea/fields/edgeFields/edgeFieldsFwd.H b/src/finiteArea/fields/edgeFields/edgeFieldsFwd.H index 9f10185f41..e8ead27a34 100644 --- a/src/finiteArea/fields/edgeFields/edgeFieldsFwd.H +++ b/src/finiteArea/fields/edgeFields/edgeFieldsFwd.H @@ -41,6 +41,7 @@ Description namespace Foam { +// Geometric field (internal + boundary) template class PatchField, class GeoMesh> class GeometricField; diff --git a/src/finiteArea/finiteArea/lnGradSchemes/lnGradScheme/lnGradScheme.C b/src/finiteArea/finiteArea/lnGradSchemes/lnGradScheme/lnGradScheme.C index d499b74192..2fbc4fbc81 100644 --- a/src/finiteArea/finiteArea/lnGradSchemes/lnGradScheme/lnGradScheme.C +++ b/src/finiteArea/finiteArea/lnGradSchemes/lnGradScheme/lnGradScheme.C @@ -138,8 +138,7 @@ lnGradScheme::lnGrad deltaCoeffs[faceI]*(vf[neighbour[faceI]] - vf[owner[faceI]]); } - typename GeometricField::Boundary& ssfb = - ssf.boundaryFieldRef(); + auto& ssfb = ssf.boundaryFieldRef(); forAll(vf.boundaryField(), patchI) { diff --git a/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolationScheme/edgeInterpolationScheme.C b/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolationScheme/edgeInterpolationScheme.C index d41009dcd8..b348c7ca0f 100644 --- a/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolationScheme/edgeInterpolationScheme.C +++ b/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolationScheme/edgeInterpolationScheme.C @@ -317,8 +317,7 @@ Foam::edgeInterpolationScheme::interpolate // Interpolate across coupled patches using given lambdas - const typename GeometricField::Boundary& - vfb = vf.boundaryField(); + const auto& vfb = vf.boundaryField(); forAll(lambdas.boundaryField(), pi) { diff --git a/src/finiteArea/interpolation/edgeInterpolation/schemes/NVDscheme/faNVDscheme.C b/src/finiteArea/interpolation/edgeInterpolation/schemes/NVDscheme/faNVDscheme.C index c69f0b143d..c58f995891 100644 --- a/src/finiteArea/interpolation/edgeInterpolation/schemes/NVDscheme/faNVDscheme.C +++ b/src/finiteArea/interpolation/edgeInterpolation/schemes/NVDscheme/faNVDscheme.C @@ -123,8 +123,7 @@ Foam::tmp Foam::faNVDscheme::weights } - GeometricField::Boundary& - bWeights = weightingFactors.boundaryFieldRef(); + auto& bWeights = weightingFactors.boundaryFieldRef(); forAll(bWeights, patchI) { diff --git a/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.C b/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.C index 01bc10a050..ee03325dc6 100644 --- a/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.C +++ b/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.C @@ -33,7 +33,7 @@ License template Foam::tmp> Foam::volSurfaceMapping::mapToSurface ( - const typename GeometricField::Boundary& df + const GeometricBoundaryField& df ) const { // Grab labels for all faces in faMesh @@ -98,7 +98,7 @@ Foam::tmp> Foam::volSurfaceMapping::mapToSurface template Foam::tmp> Foam::volSurfaceMapping::mapInternalToSurface ( - const typename GeometricField::Boundary& df + const GeometricBoundaryField& df ) const { // Grab labels for all faces in faMesh @@ -134,7 +134,7 @@ template void Foam::volSurfaceMapping::mapToVolume ( const GeometricField& af, - typename GeometricField::Boundary& bf + GeometricBoundaryField& bf ) const { // Grab labels for all faces in faMesh @@ -166,7 +166,7 @@ template void Foam::volSurfaceMapping::mapToVolume ( const tmp>& taf, - typename GeometricField::Boundary& bf + GeometricBoundaryField& bf ) const { mapToVolume(taf(), bf); diff --git a/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.H b/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.H index f5908f04a4..3138249998 100644 --- a/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.H +++ b/src/finiteArea/interpolation/volSurfaceMapping/volSurfaceMapping.H @@ -38,8 +38,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef volSurfaceMapping_H -#define volSurfaceMapping_H +#ifndef Foam_volSurfaceMapping_H +#define Foam_volSurfaceMapping_H #include "faMesh.H" #include "volMesh.H" @@ -49,6 +49,7 @@ SourceFiles namespace Foam { +// Forward Declarations template class fvPatchField; /*---------------------------------------------------------------------------*\ @@ -86,12 +87,11 @@ public: // Member Functions - //- Map Boundary field to surface + //- Map volume boundary field to surface template tmp> mapToSurface ( - const typename - GeometricField::Boundary& df + const GeometricBoundaryField& df ) const; //- Map vol Field to surface Field @@ -102,8 +102,7 @@ public: template tmp> mapInternalToSurface ( - const typename - GeometricField::Boundary& df + const GeometricBoundaryField& df ) const; //- Map surface field to volume boundary field @@ -111,7 +110,7 @@ public: void mapToVolume ( const GeometricField& af, - typename GeometricField::Boundary& bf + GeometricBoundaryField& bf ) const; //- Map surface tmp field to volume boundary field @@ -119,7 +118,7 @@ public: void mapToVolume ( const tmp>& taf, - typename GeometricField::Boundary& bf + GeometricBoundaryField& bf ) const; //- Map surface field to field diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZoneTemplates.C b/src/finiteVolume/cfdTools/general/MRF/MRFZoneTemplates.C index 8cba28a310..1a0ca0db1a 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZoneTemplates.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZoneTemplates.C @@ -227,8 +227,7 @@ void Foam::MRFZone::zero phii[internalFaces_[i]] = Zero; } - typename GeometricField::Boundary& phibf = - phi.boundaryFieldRef(); + auto& phibf = phi.boundaryFieldRef(); forAll(includedFaces_, patchi) { diff --git a/src/finiteVolume/fields/fvPatchFields/basic/sliced/slicedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/sliced/slicedFvPatchField.C index cfe2ce7414..5a2d5ba0d1 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/sliced/slicedFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/sliced/slicedFvPatchField.C @@ -40,7 +40,7 @@ Foam::slicedFvPatchField::slicedFvPatchField : fvPatchField(p, iF, Field()) { - // Set the fvPatchField to a slice of the given complete field + // Set fvPatchField to a slice of the given complete field UList::shallowCopy(p.patchSlice(completeField)); } @@ -145,9 +145,8 @@ Foam::slicedFvPatchField::clone template Foam::slicedFvPatchField::~slicedFvPatchField() { - // Set the fvPatchField storage pointer to nullptr before its destruction - // to protect the field it a slice of. - UList::shallowCopy(UList(nullptr, 0)); + // Set fvPatchField to nullptr to avoid deletion of underlying field + UList::shallowCopy(UList()); } diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/sliced/slicedFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/basic/sliced/slicedFvsPatchField.C index ef01d7d828..86d682c5a5 100644 --- a/src/finiteVolume/fields/fvsPatchFields/basic/sliced/slicedFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/basic/sliced/slicedFvsPatchField.C @@ -39,7 +39,7 @@ Foam::slicedFvsPatchField::slicedFvsPatchField : fvsPatchField(p, iF, Field()) { - // Set the fvsPatchField to a slice of the given complete field + // Set fvsPatchField to a slice of the given complete field UList::shallowCopy(p.patchSlice(completeField)); } @@ -144,9 +144,8 @@ Foam::slicedFvsPatchField::clone template Foam::slicedFvsPatchField::~slicedFvsPatchField() { - // Set the fvsPatchField storage pointer to nullptr before its destruction - // to protect the field it a slice of. - UList::shallowCopy(UList(nullptr, 0)); + // Set fvsPatchField to nullptr to avoid deletion of underlying field + UList::shallowCopy(UList()); } diff --git a/src/finiteVolume/fields/surfaceFields/surfaceFieldsFwd.H b/src/finiteVolume/fields/surfaceFields/surfaceFieldsFwd.H index 32593064f9..1a1dd8a353 100644 --- a/src/finiteVolume/fields/surfaceFields/surfaceFieldsFwd.H +++ b/src/finiteVolume/fields/surfaceFields/surfaceFieldsFwd.H @@ -44,6 +44,7 @@ SourceFiles namespace Foam { +// Geometric field (internal + boundary) template class PatchField, class GeoMesh> class GeometricField; diff --git a/src/finiteVolume/fields/volFields/volFieldsFwd.H b/src/finiteVolume/fields/volFields/volFieldsFwd.H index 7e063d23ec..8d1293f421 100644 --- a/src/finiteVolume/fields/volFields/volFieldsFwd.H +++ b/src/finiteVolume/fields/volFields/volFieldsFwd.H @@ -45,7 +45,14 @@ SourceFiles namespace Foam { +// Geometric internal field template class DimensionedField; + +// Geometric boundary field +template class PatchField, class GeoMesh> +class GeometricBoundaryField; + +// Geometric field (internal + boundary) template class PatchField, class GeoMesh> class GeometricField; @@ -61,6 +68,10 @@ template class fvPatchField; template using VolumeField = GeometricField; +//- A volume boundary field for a given Type +template +using VolumeBoundaryField = GeometricBoundaryField; + //- A volume internal field for a given Type template using VolumeInternalField = DimensionedField; diff --git a/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.C b/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.C index 8b66c491b9..ac103096b9 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.C @@ -150,10 +150,7 @@ void Foam::fv::gaussGrad::correctBoundaryConditions >& gGrad ) { - typename GeometricField - < - typename outerProduct::type, fvPatchField, volMesh - >::Boundary& gGradbf = gGrad.boundaryFieldRef(); + auto& gGradbf = gGrad.boundaryFieldRef(); forAll(vsf.boundaryField(), patchi) { diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrad.C b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrad.C index 96bf79338f..f259794f1f 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrad.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrad.C @@ -122,8 +122,7 @@ Foam::fv::cellLimitedGrad::calcGrad } - const typename GeometricField::Boundary& bsf = - vsf.boundaryField(); + const auto& bsf = vsf.boundaryField(); forAll(bsf, patchi) { diff --git a/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.H b/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.H index 8eca50c33d..a08051689c 100644 --- a/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.H +++ b/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.H @@ -35,10 +35,10 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef fvBoundaryMesh_H -#define fvBoundaryMesh_H +#ifndef Foam_fvBoundaryMesh_H +#define Foam_fvBoundaryMesh_H -#include "fvPatchList.H" +#include "fvPatch.H" #include "lduInterfacePtrsList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index 049ca8d0e7..d84884c852 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -5,8 +5,8 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2011-2017,2022 OpenFOAM Foundation + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,11 +67,7 @@ void Foam::fvMesh::clearGeomNotOldVol() MoveableMeshObject >(*this); - slicedVolScalarField::Internal* VPtr = - static_cast(VPtr_); - deleteDemandDrivenData(VPtr); - VPtr_ = nullptr; - + deleteDemandDrivenData(VPtr_); deleteDemandDrivenData(SfPtr_); deleteDemandDrivenData(magSfPtr_); deleteDemandDrivenData(CPtr_); @@ -81,11 +77,11 @@ void Foam::fvMesh::clearGeomNotOldVol() void Foam::fvMesh::updateGeomNotOldVol() { - bool haveV = (VPtr_ != nullptr); - bool haveSf = (SfPtr_ != nullptr); - bool haveMagSf = (magSfPtr_ != nullptr); - bool haveCP = (CPtr_ != nullptr); - bool haveCf = (CfPtr_ != nullptr); + const bool haveV = (VPtr_ != nullptr); + const bool haveSf = (SfPtr_ != nullptr); + const bool haveMagSf = (magSfPtr_ != nullptr); + const bool haveCP = (CPtr_ != nullptr); + const bool haveCf = (CfPtr_ != nullptr); clearGeomNotOldVol(); @@ -603,7 +599,7 @@ Foam::SolverPerformance Foam::fvMesh::solve void Foam::fvMesh::addFvPatches ( - PtrList& plist, + polyPatchList& plist, const bool validBoundary ) { @@ -626,7 +622,7 @@ void Foam::fvMesh::addFvPatches ) { // Acquire ownership of the pointers - PtrList plist(const_cast&>(p)); + polyPatchList plist(const_cast&>(p)); addFvPatches(plist, validBoundary); } @@ -970,10 +966,10 @@ void Foam::fvMesh::updateMesh(const mapPolyMesh& mpm) storeOldVol(mpm.oldCellVolumes()); // Few checks - if (VPtr_ && (V().size() != mpm.nOldCells())) + if (VPtr_ && (VPtr_->size() != mpm.nOldCells())) { FatalErrorInFunction - << "V:" << V().size() + << "V:" << VPtr_->size() << " not equal to the number of old cells " << mpm.nOldCells() << exit(FatalError); diff --git a/src/finiteVolume/fvMesh/fvMesh.H b/src/finiteVolume/fvMesh/fvMesh.H index 0c547157d6..4415f5b9a9 100644 --- a/src/finiteVolume/fvMesh/fvMesh.H +++ b/src/finiteVolume/fvMesh/fvMesh.H @@ -5,8 +5,8 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2011-2017,2022 OpenFOAM Foundation + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -47,8 +47,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef fvMesh_H -#define fvMesh_H +#ifndef Foam_fvMesh_H +#define Foam_fvMesh_H #include "polyMesh.H" #include "lduMesh.H" @@ -58,26 +58,24 @@ SourceFiles #include "fvSchemes.H" #include "fvSolution.H" #include "data.H" -#include "DimensionedField.H" #include "volFieldsFwd.H" #include "surfaceFieldsFwd.H" #include "pointFieldsFwd.H" +#include "SlicedDimensionedField.H" #include "slicedVolFieldsFwd.H" #include "slicedSurfaceFieldsFwd.H" #include "className.H" #include "SolverPerformance.H" - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { +// Forward Declarations class fvMeshLduAddressing; class volMesh; -template -class fvMatrix; +template class fvMatrix; /*---------------------------------------------------------------------------*\ Class fvMesh Declaration @@ -109,8 +107,8 @@ protected: // will take care of the old-time levels. mutable label curTimeIndex_; - //- Cell volumes old time level - mutable void* VPtr_; + //- Cell volumes + mutable SlicedDimensionedField* VPtr_; //- Cell volumes old time level mutable DimensionedField* V0Ptr_; @@ -259,7 +257,7 @@ public: //- Add boundary patches. Constructor helper void addFvPatches ( - PtrList& plist, + polyPatchList& plist, const bool validBoundary = true ); diff --git a/src/finiteVolume/fvMesh/fvMeshGeometry.C b/src/finiteVolume/fvMesh/fvMeshGeometry.C index 60cca8a48d..bfe6d43193 100644 --- a/src/finiteVolume/fvMesh/fvMeshGeometry.C +++ b/src/finiteVolume/fvMesh/fvMeshGeometry.C @@ -5,8 +5,8 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2011-2017,2022 OpenFOAM Foundation + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -183,7 +183,7 @@ const Foam::volScalarField::Internal& Foam::fvMesh::V() const DebugInFunction << "Constructing from primitiveMesh::cellVolumes()" << endl; - VPtr_ = new slicedVolScalarField::Internal + VPtr_ = new SlicedDimensionedField ( IOobject ( @@ -200,7 +200,7 @@ const Foam::volScalarField::Internal& Foam::fvMesh::V() const ); } - return *static_cast(VPtr_); + return *VPtr_; } @@ -275,15 +275,9 @@ Foam::tmp Foam::fvMesh::Vsc() const { return V0() + tFrac*(V() - V0()); } - else - { - return V(); - } - } - else - { - return V(); } + + return V(); } @@ -304,15 +298,9 @@ Foam::tmp Foam::fvMesh::Vsc0() const { return V0() + t0Frac*(V() - V0()); } - else - { - return V0(); - } - } - else - { - return V0(); } + + return V0(); } diff --git a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H index 7ef94de2ab..9f1a73a006 100644 --- a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H @@ -36,18 +36,19 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef fvPatch_H -#define fvPatch_H +#ifndef Foam_fvPatch_H +#define Foam_fvPatch_H #include "polyPatch.H" #include "labelList.H" #include "SubList.H" +#include "SubField.H" +#include "PtrList.H" #include "typeInfo.H" +#include "autoPtr.H" #include "tmp.H" #include "primitiveFields.H" -#include "SubField.H" #include "fvPatchFieldsFwd.H" -#include "autoPtr.H" #include "runTimeSelectionTables.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,8 +58,12 @@ namespace Foam // Forward Declarations class fvBoundaryMesh; +class fvPatch; class surfaceInterpolation; +//- Store lists of fvPatch as a PtrList +typedef PtrList fvPatchList; + /*---------------------------------------------------------------------------*\ Class fvPatch Declaration \*---------------------------------------------------------------------------*/ diff --git a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatchList.H b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatchList.H index b880f20ab1..bb24f438d2 100644 --- a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatchList.H +++ b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatchList.H @@ -1,57 +1,9 @@ /*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011 OpenFOAM Foundation -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Typedef - Foam::fvPatchList - Description - container classes for fvPatch + Compatibility include (MAR-2022) \*---------------------------------------------------------------------------*/ -#ifndef fvPatchList_H -#define fvPatchList_H - #include "fvPatch.H" -#include "PtrList.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -typedef PtrList fvPatchList; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif // ************************************************************************* // diff --git a/src/functionObjects/field/zeroGradient/zeroGradientTemplates.C b/src/functionObjects/field/zeroGradient/zeroGradientTemplates.C index a241a73990..7db327215b 100644 --- a/src/functionObjects/field/zeroGradient/zeroGradientTemplates.C +++ b/src/functionObjects/field/zeroGradient/zeroGradientTemplates.C @@ -37,8 +37,7 @@ bool Foam::functionObjects::zeroGradient::accept const GeometricField& input ) { - const typename GeometricField::Boundary& - patches = input.boundaryField(); + const auto& patches = input.boundaryField(); forAll(patches, patchi) { diff --git a/src/mesh/blockMesh/PDRblockMesh/PDRblockCreate.C b/src/mesh/blockMesh/PDRblockMesh/PDRblockCreate.C index b55f5fdc03..a88ec0574e 100644 --- a/src/mesh/blockMesh/PDRblockMesh/PDRblockCreate.C +++ b/src/mesh/blockMesh/PDRblockMesh/PDRblockCreate.C @@ -343,7 +343,7 @@ Foam::PDRblock::innerMesh(const IOobject& io) const ); polyMesh& pmesh = *meshPtr; - PtrList patches(patches_.size()); + polyPatchList patches(patches_.size()); label startFace = nInternalFaces(); diff --git a/src/mesh/blockMesh/blockMesh/blockMeshCreate.C b/src/mesh/blockMesh/blockMesh/blockMeshCreate.C index 0835309ce4..4edf8770ec 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshCreate.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshCreate.C @@ -333,7 +333,7 @@ Foam::blockMesh::topology(bool applyTransform) const const polyBoundaryMesh& pbmOld = origTopo.boundaryMesh(); const polyBoundaryMesh& pbmNew = topoMesh.boundaryMesh(); - PtrList newPatches(pbmOld.size()); + polyPatchList newPatches(pbmOld.size()); forAll(pbmOld, patchi) { diff --git a/src/parallel/decompose/faDecompose/faMeshDecomposition.C b/src/parallel/decompose/faDecompose/faMeshDecomposition.C index 9b58ad1680..b690998757 100644 --- a/src/parallel/decompose/faDecompose/faMeshDecomposition.C +++ b/src/parallel/decompose/faDecompose/faMeshDecomposition.C @@ -1225,7 +1225,7 @@ bool Foam::faMeshDecomposition::writeDecomposition() const faPatchList& meshPatches = boundary(); - PtrList procPatches + faPatchList procPatches ( curPatchSizes.size() + curProcessorPatchSizes.size() ); diff --git a/src/parallel/reconstruct/faReconstruct/faMeshReconstructor.C b/src/parallel/reconstruct/faReconstruct/faMeshReconstructor.C index 4f0e22e40a..b3d64b4293 100644 --- a/src/parallel/reconstruct/faReconstruct/faMeshReconstructor.C +++ b/src/parallel/reconstruct/faReconstruct/faMeshReconstructor.C @@ -495,7 +495,7 @@ void Foam::faMeshReconstructor::createMesh() auto& completeMesh = *serialAreaMesh_; // Add in non-processor boundary patches - PtrList completePatches(singlePatchEdgeLabels_.size()); + faPatchList completePatches(singlePatchEdgeLabels_.size()); forAll(completePatches, patchi) { const labelList& patchEdgeLabels = singlePatchEdgeLabels_[patchi];