diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 46375057ca..d4887e8dcd 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -805,6 +805,7 @@ $(basicPointPatchFields)/coupled/coupledPointPatchFields.C $(basicPointPatchFields)/value/valuePointPatchFields.C $(basicPointPatchFields)/fixedValue/fixedValuePointPatchFields.C $(basicPointPatchFields)/zeroGradient/zeroGradientPointPatchFields.C +$(basicPointPatchFields)/zeroValue/zeroValuePointPatchFields.C constraintPointPatchFields = $(pointPatchFields)/constraint $(constraintPointPatchFields)/cyclic/cyclicPointPatchFields.C diff --git a/src/OpenFOAM/fields/Fields/fieldTypes.C b/src/OpenFOAM/fields/Fields/fieldTypes.C index bdfb88a011..7f0efc300a 100644 --- a/src/OpenFOAM/fields/Fields/fieldTypes.C +++ b/src/OpenFOAM/fields/Fields/fieldTypes.C @@ -69,6 +69,11 @@ const Foam::word Foam::fieldTypes::zeroGradientType Foam::fieldTypes::zeroGradientTypeName_() ); +const Foam::word Foam::fieldTypes::zeroValueType +( + Foam::fieldTypes::zeroValueTypeName_() +); + // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/fields/Fields/fieldTypes.H b/src/OpenFOAM/fields/Fields/fieldTypes.H index d890277926..df5ed431e5 100644 --- a/src/OpenFOAM/fields/Fields/fieldTypes.H +++ b/src/OpenFOAM/fields/Fields/fieldTypes.H @@ -120,6 +120,12 @@ inline const char* zeroGradientTypeName_() noexcept { return "zeroGradient"; } //- A \c zeroGradient patch field type extern const word zeroGradientType; +//- A \c zeroValue patch field type +inline const char* zeroValueTypeName_() noexcept { return "zeroValue"; } + +//- A \c zeroValue patch field type +extern const word zeroValueType; + } // End namespace fieldTypes } // End namespace Foam diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.C index 166f6172c1..f7be325dd3 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2023 OpenCFD Ltd. + Copyright (C) 2023-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,7 +37,7 @@ Foam::fixedValuePointPatchField::fixedValuePointPatchField const DimensionedField& iF ) : - valuePointPatchField(p, iF) + parent_bctype(p, iF) {} @@ -49,7 +49,7 @@ Foam::fixedValuePointPatchField::fixedValuePointPatchField const Type& value ) : - valuePointPatchField(p, iF, value) + parent_bctype(p, iF, value) {} @@ -62,31 +62,44 @@ Foam::fixedValuePointPatchField::fixedValuePointPatchField IOobjectOption::readOption requireValue ) : - valuePointPatchField(p, iF, dict, requireValue) + parent_bctype(p, iF, dict, requireValue) {} template Foam::fixedValuePointPatchField::fixedValuePointPatchField ( - const fixedValuePointPatchField& ptf, + const fixedValuePointPatchField& pfld, const pointPatch& p, const DimensionedField& iF, const pointPatchFieldMapper& mapper ) : - valuePointPatchField(ptf, p, iF, mapper) + parent_bctype(pfld, p, iF, mapper) {} template Foam::fixedValuePointPatchField::fixedValuePointPatchField ( - const fixedValuePointPatchField& ptf, + const fixedValuePointPatchField& pfld, + const pointPatch& p, + const DimensionedField& iF, + const Type& value +) +: + parent_bctype(pfld, p, iF, value) +{} + + +template +Foam::fixedValuePointPatchField::fixedValuePointPatchField +( + const fixedValuePointPatchField& pfld, const DimensionedField& iF ) : - valuePointPatchField(ptf, iF) + parent_bctype(pfld, iF) {} diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.H index 1e30f2a63d..d72a645cac 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2023 OpenCFD Ltd. + Copyright (C) 2023-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,6 +56,9 @@ class fixedValuePointPatchField : public valuePointPatchField { + //- The parent boundary condition type + typedef valuePointPatchField parent_bctype; + public: //- Runtime type information @@ -113,13 +116,30 @@ public: const pointPatchFieldMapper& ); - //- Construct as copy setting internal field reference + //- Copy construct onto patch with internal field reference + //- and specified value fixedValuePointPatchField ( - const fixedValuePointPatchField&, - const DimensionedField& + const fixedValuePointPatchField& pfld, + const pointPatch& p, + const DimensionedField& iF, + const Type& value ); + //- Copy construct with internal field reference + fixedValuePointPatchField + ( + const fixedValuePointPatchField& pfld, + const DimensionedField& iF + ); + + //- Copy construct + fixedValuePointPatchField(const fixedValuePointPatchField& pfld) + : + fixedValuePointPatchField(pfld, pfld.internalField()) + {} + + //- Return a clone virtual autoPtr> clone() const { @@ -148,9 +168,8 @@ public: // Member Operators // Disable assignment operators - - virtual void operator=(const Field&){} - virtual void operator=(const Type&){} + virtual void operator=(const Field&) {} + virtual void operator=(const Type&) {} }; diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C index d623500b87..73a73d94f8 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2023 OpenCFD Ltd. + Copyright (C) 2019-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -129,26 +129,40 @@ Foam::valuePointPatchField::valuePointPatchField template Foam::valuePointPatchField::valuePointPatchField ( - const valuePointPatchField& ptf, + const valuePointPatchField& pfld, const pointPatch& p, const DimensionedField& iF, const pointPatchFieldMapper& mapper ) : - pointPatchField(ptf, p, iF, mapper), - Field(ptf, mapper) + pointPatchField(pfld, p, iF, mapper), + Field(pfld, mapper) {} template Foam::valuePointPatchField::valuePointPatchField ( - const valuePointPatchField& ptf, + const valuePointPatchField& pfld, + const pointPatch& p, + const DimensionedField& iF, + const Type& value +) +: + pointPatchField(pfld, p, iF, value), + Field(p.size(), value) +{} + + +template +Foam::valuePointPatchField::valuePointPatchField +( + const valuePointPatchField& pfld, const DimensionedField& iF ) : - pointPatchField(ptf, iF), - Field(ptf) + pointPatchField(pfld, iF), + Field(pfld) {} diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.H index 5236bb5422..868c8ab650 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2020-2023 OpenCFD Ltd. + Copyright (C) 2020-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -142,13 +142,24 @@ public: const pointPatchFieldMapper& ); - //- Construct as copy setting internal field reference + //- Copy construct onto patch with internal field reference + //- and specified value valuePointPatchField ( - const valuePointPatchField&, - const DimensionedField& + const valuePointPatchField& pfld, + const pointPatch& p, + const DimensionedField& iF, + const Type& value ); + //- Copy construct with internal field reference + valuePointPatchField + ( + const valuePointPatchField& pfld, + const DimensionedField& iF + ); + + //- Return a clone virtual autoPtr> clone() const { diff --git a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/zeroFixedValue/zeroFixedValuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/zeroValue/zeroValuePointPatchField.C similarity index 60% rename from src/mesh/snappyHexMesh/externalDisplacementMeshMover/zeroFixedValue/zeroFixedValuePointPatchField.C rename to src/OpenFOAM/fields/pointPatchFields/basic/zeroValue/zeroValuePointPatchField.C index b29ccc1191..a6e221715f 100644 --- a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/zeroFixedValue/zeroFixedValuePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/zeroValue/zeroValuePointPatchField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014 OpenFOAM Foundation - Copyright (C) 2023 OpenCFD Ltd. + Copyright (C) 2023-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,24 +26,24 @@ License \*---------------------------------------------------------------------------*/ -#include "zeroFixedValuePointPatchField.H" +#include "zeroValuePointPatchField.H" -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::zeroFixedValuePointPatchField::zeroFixedValuePointPatchField +Foam::zeroValuePointPatchField::zeroValuePointPatchField ( const pointPatch& p, const DimensionedField& iF ) : // Field is zero - fixedValuePointPatchField(p, iF, Type(Zero)) + parent_bctype(p, iF, Type(Zero)) {} template -Foam::zeroFixedValuePointPatchField::zeroFixedValuePointPatchField +Foam::zeroValuePointPatchField::zeroValuePointPatchField ( const pointPatch& p, const DimensionedField& iF, @@ -51,48 +51,45 @@ Foam::zeroFixedValuePointPatchField::zeroFixedValuePointPatchField ) : // Field is zero - fixedValuePointPatchField(p, iF, Type(Zero)) -{} - - -template -Foam::zeroFixedValuePointPatchField::zeroFixedValuePointPatchField -( - const zeroFixedValuePointPatchField& ptf, - const pointPatch& p, - const DimensionedField& iF, - const pointPatchFieldMapper& mapper -) -: - // Field is zero : no mapping needed - fixedValuePointPatchField(p, iF, Type(Zero)) -{} - - -template -Foam::zeroFixedValuePointPatchField::zeroFixedValuePointPatchField -( - const zeroFixedValuePointPatchField& ptf -) -: - fixedValuePointPatchField(ptf) + parent_bctype(p, iF, Type(Zero)) { - // Field is zero. For safety, re-assign - valuePointPatchField::operator=(Type(Zero)); + pointPatchFieldBase::readDict(dict); } template -Foam::zeroFixedValuePointPatchField::zeroFixedValuePointPatchField +Foam::zeroValuePointPatchField::zeroValuePointPatchField ( - const zeroFixedValuePointPatchField& ptf, + const zeroValuePointPatchField& pfld, + const pointPatch& p, + const DimensionedField& iF, + const pointPatchFieldMapper& +) +: + // Field is zero. No mapping + parent_bctype(pfld, p, iF, Type(Zero)) +{} + + +template +Foam::zeroValuePointPatchField::zeroValuePointPatchField +( + const zeroValuePointPatchField& pfld, const DimensionedField& iF ) : - fixedValuePointPatchField(ptf, iF) + // Field is zero + parent_bctype(pfld, pfld.patch(), iF, Type(Zero)) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::zeroValuePointPatchField::write(Ostream& os) const { - // Field is zero. For safety, re-assign - valuePointPatchField::operator=(Type(Zero)); + pointPatchField::write(os); + // Without writeValueEntry() since the value == zero } diff --git a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/zeroFixedValue/zeroFixedValuePointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/basic/zeroValue/zeroValuePointPatchField.H similarity index 55% rename from src/mesh/snappyHexMesh/externalDisplacementMeshMover/zeroFixedValue/zeroFixedValuePointPatchField.H rename to src/OpenFOAM/fields/pointPatchFields/basic/zeroValue/zeroValuePointPatchField.H index 15379495a2..259a1733f1 100644 --- a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/zeroFixedValue/zeroFixedValuePointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/basic/zeroValue/zeroValuePointPatchField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014 OpenFOAM Foundation + Copyright (C) 2023-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -24,26 +25,26 @@ License along with OpenFOAM. If not, see . Class - Foam::zeroFixedValuePointPatchField + Foam::zeroValuePointPatchField Description - Enables the specification of a zero fixed value boundary condition. + Specifies a zero fixed value boundary condition Example of the boundary condition specification: \verbatim inlet { - type zeroFixedValue; + type zeroValue; } \endverbatim SourceFiles - zeroFixedValuePointPatchField.C + zeroValuePointPatchField.C \*---------------------------------------------------------------------------*/ -#ifndef Foam_zeroFixedValuePointPatchField_H -#define Foam_zeroFixedValuePointPatchField_H +#ifndef Foam_zeroValuePointPatchField_H +#define Foam_zeroValuePointPatchField_H #include "fixedValuePointPatchField.H" @@ -53,58 +54,62 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class zeroFixedValuePointPatchField Declaration + Class zeroValuePointPatchField Declaration \*---------------------------------------------------------------------------*/ template -class zeroFixedValuePointPatchField +class zeroValuePointPatchField : public fixedValuePointPatchField { + //- The parent boundary condition type + typedef fixedValuePointPatchField parent_bctype; + public: //- Runtime type information - TypeName("zeroFixedValue"); + TypeName("zeroValue"); // Constructors //- Construct from patch and internal field - zeroFixedValuePointPatchField + zeroValuePointPatchField ( const pointPatch&, const DimensionedField& ); //- Construct from patch, internal field and dictionary - zeroFixedValuePointPatchField + zeroValuePointPatchField ( const pointPatch&, const DimensionedField&, const dictionary& ); - //- Construct by mapping given patch field onto a new patch - zeroFixedValuePointPatchField + //- Copy construct onto a new patch + zeroValuePointPatchField ( - const zeroFixedValuePointPatchField&, - const pointPatch&, - const DimensionedField&, + const zeroValuePointPatchField& pfld, + const pointPatch& p, + const DimensionedField& iF, const pointPatchFieldMapper& ); - //- Construct as copy - zeroFixedValuePointPatchField + //- Copy construct with internal field reference + zeroValuePointPatchField ( - const zeroFixedValuePointPatchField& + const zeroValuePointPatchField& pfld, + const DimensionedField& iF ); - //- Construct as copy setting internal field reference - zeroFixedValuePointPatchField - ( - const zeroFixedValuePointPatchField&, - const DimensionedField& - ); + //- Copy construct + zeroValuePointPatchField(const zeroValuePointPatchField& pfld) + : + zeroValuePointPatchField(pfld, pfld.internalField()) + {} + //- Return a clone virtual autoPtr> clone() const @@ -120,6 +125,39 @@ public: { return pointPatchField::Clone(*this, iF); } + + + // Member Functions + + //- True: this patch field fixes a value. + virtual bool fixesValue() const { return true; } + + //- False: this patch field is not altered by assignment. + virtual bool assignable() const { return false; } + + //- Write (without "value" entry) + virtual void write(Ostream& os) const; + + + // Member Operators + + // Disable assignment operators + virtual void operator=(const valuePointPatchField&) {} + virtual void operator=(const pointPatchField&) {} + virtual void operator=(const Field&) {} + virtual void operator=(const Type&) {} + + // Disable forced assignment operators + virtual void operator==(const valuePointPatchField&) {} + virtual void operator==(const pointPatchField&) {} + virtual void operator==(const Field&) {} + virtual void operator==(const Type&) {} + + // Prevent automatic comparison rewriting (c++20) + bool operator!=(const valuePointPatchField&) const = delete; + bool operator!=(const pointPatchField&) const = delete; + bool operator!=(const Field&) const = delete; + bool operator!=(const Type&) const = delete; }; @@ -130,7 +168,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository -# include "zeroFixedValuePointPatchField.C" + #include "zeroValuePointPatchField.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/zeroFixedValue/zeroFixedValuePointPatchFields.C b/src/OpenFOAM/fields/pointPatchFields/basic/zeroValue/zeroValuePointPatchFields.C similarity index 84% rename from src/mesh/snappyHexMesh/externalDisplacementMeshMover/zeroFixedValue/zeroFixedValuePointPatchFields.C rename to src/OpenFOAM/fields/pointPatchFields/basic/zeroValue/zeroValuePointPatchFields.C index 52579cc678..ab783e492c 100644 --- a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/zeroFixedValue/zeroFixedValuePointPatchFields.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/zeroValue/zeroValuePointPatchFields.C @@ -25,21 +25,15 @@ License \*---------------------------------------------------------------------------*/ -#include "zeroFixedValuePointPatchFields.H" +#include "zeroValuePointPatchFields.H" #include "pointPatchFields.H" #include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -makePointPatchFields(zeroFixedValue); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam + makePointPatchFields(zeroValue); +} // ************************************************************************* // diff --git a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/zeroFixedValue/zeroFixedValuePointPatchFields.H b/src/OpenFOAM/fields/pointPatchFields/basic/zeroValue/zeroValuePointPatchFields.H similarity index 85% rename from src/mesh/snappyHexMesh/externalDisplacementMeshMover/zeroFixedValue/zeroFixedValuePointPatchFields.H rename to src/OpenFOAM/fields/pointPatchFields/basic/zeroValue/zeroValuePointPatchFields.H index 466f4a5722..41f391ebff 100644 --- a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/zeroFixedValue/zeroFixedValuePointPatchFields.H +++ b/src/OpenFOAM/fields/pointPatchFields/basic/zeroValue/zeroValuePointPatchFields.H @@ -23,20 +23,12 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -InClass - Foam::zeroFixedValuePointPatchFields - -Description - -SourceFiles - zeroFixedValuePointPatchFields.C - \*---------------------------------------------------------------------------*/ -#ifndef zeroFixedValuePointPatchFields_H -#define zeroFixedValuePointPatchFields_H +#ifndef Foam_zeroValuePointPatchFields_H +#define Foam_zeroValuePointPatchFields_H -#include "zeroFixedValuePointPatchField.H" +#include "zeroValuePointPatchField.H" #include "fieldTypes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -46,7 +38,7 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePointPatchFieldTypedefs(zeroFixedValue); +makePointPatchFieldTypedefs(zeroValue); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C index 87b4bc9c5f..a4b0a8cb44 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C @@ -60,13 +60,13 @@ Foam::pointPatchField::pointPatchField template Foam::pointPatchField::pointPatchField ( - const pointPatchField& ptf, + const pointPatchField& pfld, const pointPatch& p, const DimensionedField& iF, const pointPatchFieldMapper& ) : - pointPatchFieldBase(ptf, p), + pointPatchFieldBase(pfld, p), internalField_(iF) {} @@ -74,22 +74,25 @@ Foam::pointPatchField::pointPatchField template Foam::pointPatchField::pointPatchField ( - const pointPatchField& ptf + const pointPatchField& pfld, + const pointPatch& p, + const DimensionedField& iF, + const Type& ) : - pointPatchFieldBase(ptf), - internalField_(ptf.internalField_) + pointPatchFieldBase(pfld, p), + internalField_(iF) {} template Foam::pointPatchField::pointPatchField ( - const pointPatchField& ptf, + const pointPatchField& pfld, const DimensionedField& iF ) : - pointPatchFieldBase(ptf), + pointPatchFieldBase(pfld), internalField_(iF) {} diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H index a24e8b7aee..0be9a186e6 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H @@ -150,6 +150,12 @@ public: return Foam::fieldTypes::zeroGradientType; } + //- The type name for \c zeroValue patch fields + static const word& zeroValueType() noexcept + { + return Foam::fieldTypes::zeroValueType; + } + // Member Functions @@ -351,16 +357,29 @@ public: const pointPatchFieldMapper& ); - //- Construct as copy - pointPatchField(const pointPatchField&); - - //- Construct as copy setting internal field reference + //- Copy construct onto a new patch with (unused) value pointPatchField ( - const pointPatchField&, - const DimensionedField& + const pointPatchField& pfld, + const pointPatch& p, + const DimensionedField& iF, + const Type& value /* (unused) */ ); + //- Copy construct with internal field reference + pointPatchField + ( + const pointPatchField& pfld, + const DimensionedField& iF + ); + + //- Copy construct + pointPatchField(const pointPatchField& pfld) + : + pointPatchField(pfld, pfld.internalField()) + {} + + //- Clone patch field with its own internal field reference virtual autoPtr> clone() const = 0; @@ -590,22 +609,19 @@ public: const Pstream::commsTypes commsType = Pstream::commsTypes::buffered ); - //- Initialise the evaluation of the patch field after a local - // operation - virtual void initEvaluateLocal - ( - const Pstream::commsTypes commsType = - Pstream::commsTypes::buffered - ) - {} + //- Initialise the evaluation of the patch field after a local operation + virtual void initEvaluateLocal + ( + const Pstream::commsTypes commsType = Pstream::commsTypes::buffered + ) + {} - //- Evaluate the patch field after a local operation (e.g. *=) - virtual void evaluateLocal - ( - const Pstream::commsTypes commsType = - Pstream::commsTypes::buffered - ) - {} + //- Evaluate the patch field after a local operation (e.g. *=) + virtual void evaluateLocal + ( + const Pstream::commsTypes commsType = Pstream::commsTypes::buffered + ) + {} // Other diff --git a/src/finiteArea/Make/files b/src/finiteArea/Make/files index 94be44a0e1..2e21600985 100644 --- a/src/finiteArea/Make/files +++ b/src/finiteArea/Make/files @@ -48,12 +48,13 @@ basicFaPatchFields = $(faPatchFields)/basic $(basicFaPatchFields)/calculated/calculatedFaPatchFields.C $(basicFaPatchFields)/extrapolatedCalculated/extrapolatedCalculatedFaPatchFields.C $(basicFaPatchFields)/coupled/coupledFaPatchFields.C -$(basicFaPatchFields)/zeroGradient/zeroGradientFaPatchFields.C $(basicFaPatchFields)/fixedValue/fixedValueFaPatchFields.C $(basicFaPatchFields)/fixedGradient/fixedGradientFaPatchFields.C $(basicFaPatchFields)/mixed/mixedFaPatchFields.C $(basicFaPatchFields)/sliced/slicedFaPatchFields.C $(basicFaPatchFields)/transform/transformFaPatchFields.C +$(basicFaPatchFields)/zeroGradient/zeroGradientFaPatchFields.C +$(basicFaPatchFields)/zeroValue/zeroValueFaPatchFields.C constraintFaPatchFields = $(faPatchFields)/constraint $(constraintFaPatchFields)/empty/emptyFaPatchFields.C @@ -84,6 +85,7 @@ $(basicFaePatchFields)/calculated/calculatedFaePatchFields.C $(basicFaePatchFields)/coupled/coupledFaePatchFields.C $(basicFaePatchFields)/fixedValue/fixedValueFaePatchFields.C $(basicFaePatchFields)/sliced/slicedFaePatchFields.C +$(basicFaePatchFields)/zeroValue/zeroValueFaePatchFields.C constraintFaePatchFields = $(faePatchFields)/constraint $(constraintFaePatchFields)/empty/emptyFaePatchFields.C diff --git a/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.C b/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.C index f4d1e26592..166059af44 100644 --- a/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd + Copyright (C) 2023-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -65,17 +66,6 @@ Foam::fixedValueFaPatchField::fixedValueFaPatchField {} -template -Foam::fixedValueFaPatchField::fixedValueFaPatchField -( - const fixedValueFaPatchField& ptf, - const DimensionedField& iF -) -: - faPatchField(ptf, iF) -{} - - template Foam::fixedValueFaPatchField::fixedValueFaPatchField ( @@ -92,10 +82,24 @@ Foam::fixedValueFaPatchField::fixedValueFaPatchField template Foam::fixedValueFaPatchField::fixedValueFaPatchField ( - const fixedValueFaPatchField& ptf + const fixedValueFaPatchField& pfld, + const faPatch& p, + const DimensionedField& iF, + const Type& value ) : - faPatchField(ptf) + faPatchField(pfld, p, iF, value) +{} + + +template +Foam::fixedValueFaPatchField::fixedValueFaPatchField +( + const fixedValueFaPatchField& pfld, + const DimensionedField& iF +) +: + faPatchField(pfld, iF) {} @@ -108,6 +112,7 @@ Foam::fixedValueFaPatchField::valueInternalCoeffs const tmp& ) const { + // No contribution from internal values return tmp>::New(this->size(), Foam::zero{}); } diff --git a/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.H b/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.H index fa3f891e13..8e1e124cb0 100644 --- a/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2023 OpenCFD Ltd. + Copyright (C) 2023-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -100,19 +100,30 @@ public: const faPatchFieldMapper& ); - //- Construct as copy + //- Copy construct onto a new patch with internal field reference + //- and specified value fixedValueFaPatchField ( - const fixedValueFaPatchField& + const fixedValueFaPatchField& pfld, + const faPatch& p, + const DimensionedField& iF, + const Type& value ); - //- Construct as copy setting internal field reference + //- Copy construct with internal field reference fixedValueFaPatchField ( - const fixedValueFaPatchField&, - const DimensionedField& + const fixedValueFaPatchField& pfld, + const DimensionedField& iF ); + //- Copy construct + fixedValueFaPatchField(const fixedValueFaPatchField& pfld) + : + fixedValueFaPatchField(pfld, pfld.internalField()) + {} + + //- Return clone virtual tmp> clone() const { diff --git a/src/finiteArea/fields/faPatchFields/basic/zeroValue/zeroValueFaPatchField.C b/src/finiteArea/fields/faPatchFields/basic/zeroValue/zeroValueFaPatchField.C new file mode 100644 index 0000000000..bfa5e96ae0 --- /dev/null +++ b/src/finiteArea/fields/faPatchFields/basic/zeroValue/zeroValueFaPatchField.C @@ -0,0 +1,136 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023-2025 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 . + +\*---------------------------------------------------------------------------*/ + +#include "zeroValueFaPatchField.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::zeroValueFaPatchField::zeroValueFaPatchField +( + const faPatch& p, + const DimensionedField& iF +) +: + // Field is zero + parent_bctype(p, iF, Type(Zero)) +{} + + +template +Foam::zeroValueFaPatchField::zeroValueFaPatchField +( + const faPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + // Field is zero + parent_bctype(p, iF, Type(Zero)) +{ + faPatchFieldBase::readDict(dict); +} + + +template +Foam::zeroValueFaPatchField::zeroValueFaPatchField +( + const zeroValueFaPatchField& pfld, + const faPatch& p, + const DimensionedField& iF, + const faPatchFieldMapper& +) +: + // Field is zero. No mapping + parent_bctype(pfld, p, iF, Type(Zero)) +{} + + +template +Foam::zeroValueFaPatchField::zeroValueFaPatchField +( + const zeroValueFaPatchField& pfld, + const DimensionedField& iF +) +: + // Field is zero + parent_bctype(pfld, pfld.patch(), iF, Type(Zero)) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::tmp> +Foam::zeroValueFaPatchField::valueInternalCoeffs +( + const tmp& +) const +{ + // No contribution from internal values + return tmp>::New(this->size(), Foam::zero{}); +} + + +template +Foam::tmp> +Foam::zeroValueFaPatchField::valueBoundaryCoeffs +( + const tmp& +) const +{ + // Patch field is zero + return tmp>::New(this->size(), Foam::zero{}); +} + + +template +Foam::tmp> +Foam::zeroValueFaPatchField::gradientInternalCoeffs() const +{ + return -pTraits::one*this->patch().deltaCoeffs(); +} + + +template +Foam::tmp> +Foam::zeroValueFaPatchField::gradientBoundaryCoeffs() const +{ + // Patch field is zero + return tmp>::New(this->size(), Foam::zero{}); +} + + +template +void Foam::zeroValueFaPatchField::write(Ostream& os) const +{ + faPatchField::write(os); + // Without writeValueEntry() since the value == zero +} + + +// ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/basic/zeroValue/zeroValueFaPatchField.H b/src/finiteArea/fields/faPatchFields/basic/zeroValue/zeroValueFaPatchField.H new file mode 100644 index 0000000000..5d32319dc7 --- /dev/null +++ b/src/finiteArea/fields/faPatchFields/basic/zeroValue/zeroValueFaPatchField.H @@ -0,0 +1,222 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023-2025 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::zeroValueFaPatchField + +Description + Specifies a zero fixed value boundary condition. + + Example of the boundary condition specification: + \verbatim + inlet + { + type zeroValue; + } + \endverbatim + +SourceFiles + zeroValueFaPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Foam_zeroValueFaPatchField_H +#define Foam_zeroValueFaPatchField_H + +#include "fixedValueFaPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class zeroValueFaPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template +class zeroValueFaPatchField +: + public fixedValueFaPatchField +{ + //- The parent boundary condition type + typedef fixedValueFaPatchField parent_bctype; + +public: + + //- Runtime type information + TypeName("zeroValue"); + + + // Constructors + + //- Construct from patch and internal field + zeroValueFaPatchField + ( + const faPatch& p, + const DimensionedField& iF + ); + + //- Construct from patch, internal field and dictionary + zeroValueFaPatchField + ( + const faPatch& p, + const DimensionedField& iF, + const dictionary& dict + ); + + //- Copy construct onto a new patch (no mapping needed) + zeroValueFaPatchField + ( + const zeroValueFaPatchField& pfld, + const faPatch& p, + const DimensionedField& iF, + const faPatchFieldMapper& + ); + + //- Copy construct with internal field reference + zeroValueFaPatchField + ( + const zeroValueFaPatchField& pfld, + const DimensionedField& iF + ); + + //- Copy construct + zeroValueFaPatchField(const zeroValueFaPatchField& pfld) + : + zeroValueFaPatchField(pfld, pfld.internalField()) + {} + + + //- Construct and return a clone + virtual tmp> clone() const + { + return tmp> + ( + new zeroValueFaPatchField(*this) + ); + } + + //- Construct and return a clone setting internal field reference + virtual tmp> clone + ( + const DimensionedField& iF + ) const + { + return tmp> + ( + new zeroValueFaPatchField(*this, iF) + ); + } + + + // Member Functions + + //- True: this patch field fixes a value. + virtual bool fixesValue() const { return true; } + + //- False: this patch field is not altered by assignment. + virtual bool assignable() const { return false; } + + //- Write (without "value" entry) + virtual void write(Ostream& os) const; + + + // Evaluation Functions + + //- Return the matrix diagonal coefficients corresponding to the + //- evaluation of the value of this patchField with given weights + virtual tmp> valueInternalCoeffs + ( + const tmp& + ) const; + + //- Return the matrix source coefficients corresponding to the + //- evaluation of the value of this patchField with given weights + virtual tmp> valueBoundaryCoeffs + ( + const tmp& + ) const; + + //- Return the matrix diagonal coefficients corresponding to the + //- evaluation of the gradient of this patchField + virtual tmp> gradientInternalCoeffs() const; + + //- Return the matrix source coefficients corresponding to the + //- evaluation of the gradient of this patchField + virtual tmp> gradientBoundaryCoeffs() const; + + + // Member Operators + + // Disable assignment operators + virtual void operator=(const UList&) {} + + virtual void operator=(const faPatchField&) {} + virtual void operator+=(const faPatchField&) {} + virtual void operator-=(const faPatchField&) {} + virtual void operator*=(const faPatchField&) {} + virtual void operator/=(const faPatchField&) {} + + virtual void operator+=(const Field&) {} + virtual void operator-=(const Field&) {} + + virtual void operator*=(const Field&) {} + virtual void operator/=(const Field&) {} + + virtual void operator=(const Type&) {} + virtual void operator+=(const Type&) {} + virtual void operator-=(const Type&) {} + virtual void operator*=(const scalar) {} + virtual void operator/=(const scalar) {} + + + // Disable forced assignment operators + virtual void operator==(const faPatchField&) {} + virtual void operator==(const Field&) {} + virtual void operator==(const Type&) {} + + // Prevent automatic comparison rewriting (c++20) + bool operator!=(const faPatchField&) const = delete; + bool operator!=(const Field&) const = delete; + bool operator!=(const Type&) const = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "zeroValueFaPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/basic/zeroValue/zeroValueFaPatchFields.C b/src/finiteArea/fields/faPatchFields/basic/zeroValue/zeroValueFaPatchFields.C new file mode 100644 index 0000000000..659f8cf9a1 --- /dev/null +++ b/src/finiteArea/fields/faPatchFields/basic/zeroValue/zeroValueFaPatchFields.C @@ -0,0 +1,40 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023 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 . + +\*---------------------------------------------------------------------------*/ + +#include "faPatchFields.H" +#include "zeroValueFaPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "areaFaMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + makeFaPatchFields(zeroValue); +} + +// ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/basic/zeroValue/zeroValueFaPatchFields.H b/src/finiteArea/fields/faPatchFields/basic/zeroValue/zeroValueFaPatchFields.H new file mode 100644 index 0000000000..a0e3471a4e --- /dev/null +++ b/src/finiteArea/fields/faPatchFields/basic/zeroValue/zeroValueFaPatchFields.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef Foam_zeroValueFaPatchFields_H +#define Foam_zeroValueFaPatchFields_H + +#include "zeroValueFaPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makeFaPatchTypeFieldTypedefs(zeroValue); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.C b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.C index 16bdf22d5e..d4d3a5c929 100644 --- a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.C +++ b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.C @@ -168,24 +168,27 @@ Foam::faPatchField::faPatchField template Foam::faPatchField::faPatchField ( - const faPatchField& ptf + const faPatchField& pfld, + const faPatch& p, + const DimensionedField& iF, + const Type& value ) : - faPatchFieldBase(ptf), - Field(ptf), - internalField_(ptf.internalField_) + faPatchFieldBase(pfld, p), + Field(p.size(), value), + internalField_(iF) {} template Foam::faPatchField::faPatchField ( - const faPatchField& ptf, + const faPatchField& pfld, const DimensionedField& iF ) : - faPatchFieldBase(ptf), - Field(ptf), + faPatchFieldBase(pfld), + Field(pfld), internalField_(iF) {} diff --git a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H index 4ec0907ac7..de8b96c5d1 100644 --- a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H +++ b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H @@ -162,6 +162,12 @@ public: return Foam::fieldTypes::zeroGradientType; } + //- The type name for \c zeroValue patch fields + static const word& zeroValueType() noexcept + { + return Foam::fieldTypes::zeroValueType; + } + // Member Functions @@ -403,16 +409,30 @@ public: const faPatchFieldMapper& ); - //- Construct as copy - faPatchField(const faPatchField&); - - //- Construct as copy setting internal field reference + //- Copy construct onto a new patch with internal field reference + //- and specified value faPatchField ( - const faPatchField&, - const DimensionedField& + const faPatchField& pfld, + const faPatch& p, + const DimensionedField& iF, + const Type& value ); + //- Copy construct with internal field reference + faPatchField + ( + const faPatchField& pfld, + const DimensionedField& iF + ); + + //- Copy construct + faPatchField(const faPatchField& pfld) + : + faPatchField(pfld, pfld.internalField()) + {} + + //- Clone patch field with its own internal field reference virtual tmp> clone() const { @@ -622,7 +642,7 @@ public: //- evaluation of the value of this patchField with given weights virtual tmp> valueInternalCoeffs ( - const tmp>& + const tmp& ) const { NotImplemented; @@ -633,7 +653,7 @@ public: //- evaluation of the value of this patchField with given weights virtual tmp> valueBoundaryCoeffs ( - const tmp>& + const tmp& ) const { NotImplemented; diff --git a/src/finiteArea/fields/faePatchFields/basic/fixedValue/fixedValueFaePatchField.C b/src/finiteArea/fields/faePatchFields/basic/fixedValue/fixedValueFaePatchField.C index 6d92628dda..bac94a5fd7 100644 --- a/src/finiteArea/fields/faePatchFields/basic/fixedValue/fixedValueFaePatchField.C +++ b/src/finiteArea/fields/faePatchFields/basic/fixedValue/fixedValueFaePatchField.C @@ -66,17 +66,6 @@ Foam::fixedValueFaePatchField::fixedValueFaePatchField {} -template -Foam::fixedValueFaePatchField::fixedValueFaePatchField -( - const fixedValueFaePatchField& ptf, - const DimensionedField& iF -) -: - faePatchField(ptf, iF) -{} - - template Foam::fixedValueFaePatchField::fixedValueFaePatchField ( @@ -93,10 +82,24 @@ Foam::fixedValueFaePatchField::fixedValueFaePatchField template Foam::fixedValueFaePatchField::fixedValueFaePatchField ( - const fixedValueFaePatchField& ptf + const fixedValueFaePatchField& pfld, + const faPatch& p, + const DimensionedField& iF, + const Type& value ) : - faePatchField(ptf) + faePatchField(pfld, p, iF, value) +{} + + +template +Foam::fixedValueFaePatchField::fixedValueFaePatchField +( + const fixedValueFaePatchField& pfld, + const DimensionedField& iF +) +: + faePatchField(pfld, iF) {} diff --git a/src/finiteArea/fields/faePatchFields/basic/fixedValue/fixedValueFaePatchField.H b/src/finiteArea/fields/faePatchFields/basic/fixedValue/fixedValueFaePatchField.H index b84e735304..42c632b1f8 100644 --- a/src/finiteArea/fields/faePatchFields/basic/fixedValue/fixedValueFaePatchField.H +++ b/src/finiteArea/fields/faePatchFields/basic/fixedValue/fixedValueFaePatchField.H @@ -100,19 +100,29 @@ public: const faPatchFieldMapper& ); - //- Construct as copy + //- Copy construct onto new patch with specified value fixedValueFaePatchField ( - const fixedValueFaePatchField& + const fixedValueFaePatchField& pfld, + const faPatch& p, + const DimensionedField& iF, + const Type& value ); //- Construct as copy setting internal field reference fixedValueFaePatchField ( - const fixedValueFaePatchField&, - const DimensionedField& + const fixedValueFaePatchField& pfld, + const DimensionedField& iF ); + //- Construct as copy + fixedValueFaePatchField(const fixedValueFaePatchField& pfld) + : + fixedValueFaePatchField(pfld, pfld.internalField()) + {} + + //- Return clone virtual tmp> clone() const { diff --git a/src/finiteArea/fields/faePatchFields/basic/zeroValue/zeroValueFaePatchField.C b/src/finiteArea/fields/faePatchFields/basic/zeroValue/zeroValueFaePatchField.C new file mode 100644 index 0000000000..2d42f8ec58 --- /dev/null +++ b/src/finiteArea/fields/faePatchFields/basic/zeroValue/zeroValueFaePatchField.C @@ -0,0 +1,95 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023-2025 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 . + +\*---------------------------------------------------------------------------*/ + +#include "zeroValueFaePatchField.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::zeroValueFaePatchField::zeroValueFaePatchField +( + const faPatch& p, + const DimensionedField& iF +) +: + // Field is zero + parent_bctype(p, iF, Type(Zero)) +{} + + +template +Foam::zeroValueFaePatchField::zeroValueFaePatchField +( + const faPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + // Field is zero + parent_bctype(p, iF, Type(Zero)) +{ + faePatchFieldBase::readDict(dict); +} + + +template +Foam::zeroValueFaePatchField::zeroValueFaePatchField +( + const zeroValueFaePatchField& pfld, + const faPatch& p, + const DimensionedField& iF, + const faPatchFieldMapper& +) +: + // Field is zero. No mapping + parent_bctype(pfld, p, iF, Type(Zero)) +{} + + +template +Foam::zeroValueFaePatchField::zeroValueFaePatchField +( + const zeroValueFaePatchField& pfld, + const DimensionedField& iF +) +: + // Field is zero + parent_bctype(pfld, pfld.patch(), iF, Type(Zero)) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::zeroValueFaePatchField::write(Ostream& os) const +{ + faePatchField::write(os); + // Without writeValueEntry() since the value == zero +} + + +// ************************************************************************* // diff --git a/src/finiteArea/fields/faePatchFields/basic/zeroValue/zeroValueFaePatchField.H b/src/finiteArea/fields/faePatchFields/basic/zeroValue/zeroValueFaePatchField.H new file mode 100644 index 0000000000..16ba19f937 --- /dev/null +++ b/src/finiteArea/fields/faePatchFields/basic/zeroValue/zeroValueFaePatchField.H @@ -0,0 +1,197 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023-2025 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::zeroValueFaePatchField + +Description + Specifies a zero fixed value boundary condition. + +Usage + Example of the boundary condition specification: + \verbatim + + { + type zeroValue; + } + \endverbatim + +SourceFiles + zeroValueFaePatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Foam_zeroValueFaePatchField_H +#define Foam_zeroValueFaePatchField_H + +#include "fixedValueFaePatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class zeroValueFaePatchField Declaration +\*---------------------------------------------------------------------------*/ + +template +class zeroValueFaePatchField +: + public fixedValueFaePatchField +{ + //- The parent boundary condition type + typedef fixedValueFaePatchField parent_bctype; + +public: + + //- Runtime type information + TypeName("zeroValue"); + + + // Constructors + + //- Construct from patch and internal field + zeroValueFaePatchField + ( + const faPatch& p, + const DimensionedField& iF + ); + + //- Construct from patch, internal field and dictionary + zeroValueFaePatchField + ( + const faPatch& p, + const DimensionedField& iF, + const dictionary& dict + ); + + //- Copy construct onto a new patch (no mapping needed) + //- onto a new patch + zeroValueFaePatchField + ( + const zeroValueFaePatchField& pfld, + const faPatch& p, + const DimensionedField& iF, + const faPatchFieldMapper& + ); + + //- Copy construct with internal field reference + zeroValueFaePatchField + ( + const zeroValueFaePatchField& pfld, + const DimensionedField& iF + ); + + //- Copy construct + zeroValueFaePatchField(const zeroValueFaePatchField& pfld) + : + zeroValueFaePatchField(pfld, pfld.internalField()) + {} + + + //- Return clone + virtual tmp> clone() const + { + return faePatchField::Clone(*this); + } + + //- Clone with an internal field reference + virtual tmp> clone + ( + const DimensionedField& iF + ) const + { + return faePatchField::Clone(*this, iF); + } + + + //- Destructor + virtual ~zeroValueFaePatchField() = default; + + + // Member Functions + + //- True: this patch field fixes a value. + virtual bool fixesValue() const { return true; } + + //- False: this patch field is not altered by assignment. + virtual bool assignable() const { return false; } + + //- Write (without "value" entry) + virtual void write(Ostream& os) const; + + + // Member Operators + + // Disable assignment operators + virtual void operator=(const UList&) {} + + virtual void operator=(const faePatchField&) {} + virtual void operator+=(const faePatchField&) {} + virtual void operator-=(const faePatchField&) {} + virtual void operator*=(const faePatchField&) {} + virtual void operator/=(const faePatchField&) {} + + virtual void operator+=(const Field&) {} + virtual void operator-=(const Field&) {} + + virtual void operator*=(const Field&) {} + virtual void operator/=(const Field&) {} + + virtual void operator=(const Type&) {} + virtual void operator+=(const Type&) {} + virtual void operator-=(const Type&) {} + virtual void operator*=(const scalar) {} + virtual void operator/=(const scalar) {} + + + // Disable forced assignment operators + virtual void operator==(const faePatchField&) {} + virtual void operator==(const Field&) {} + virtual void operator==(const Type&) {} + + // Prevent automatic comparison rewriting (c++20) + bool operator!=(const faePatchField&) const = delete; + bool operator!=(const Field&) const = delete; + bool operator!=(const Type&) const = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "zeroValueFaePatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteArea/fields/faePatchFields/basic/zeroValue/zeroValueFaePatchFields.C b/src/finiteArea/fields/faePatchFields/basic/zeroValue/zeroValueFaePatchFields.C new file mode 100644 index 0000000000..f50db97160 --- /dev/null +++ b/src/finiteArea/fields/faePatchFields/basic/zeroValue/zeroValueFaePatchFields.C @@ -0,0 +1,40 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023 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 . + +\*---------------------------------------------------------------------------*/ + +#include "zeroValueFaePatchFields.H" +#include "faePatchFields.H" +#include "edgeFaMesh.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + makeFaePatchFields(zeroValue); +} + +// ************************************************************************* // diff --git a/src/finiteArea/fields/faePatchFields/basic/zeroValue/zeroValueFaePatchFields.H b/src/finiteArea/fields/faePatchFields/basic/zeroValue/zeroValueFaePatchFields.H new file mode 100644 index 0000000000..a114c5cd0a --- /dev/null +++ b/src/finiteArea/fields/faePatchFields/basic/zeroValue/zeroValueFaePatchFields.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef Foam_zeroValueFaePatchFields_H +#define Foam_zeroValueFaePatchFields_H + +#include "zeroValueFaePatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makeFaePatchTypeFieldTypedefs(zeroValue); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.C b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.C index 3de23895c3..4d7acbb14b 100644 --- a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.C +++ b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.C @@ -158,24 +158,27 @@ Foam::faePatchField::faePatchField template Foam::faePatchField::faePatchField ( - const faePatchField& ptf + const faePatchField& pfld, + const faPatch& p, + const DimensionedField& iF, + const Type& value ) : - faePatchFieldBase(ptf), - Field(ptf), - internalField_(ptf.internalField_) + faePatchFieldBase(pfld, p), + Field(p.size(), value), + internalField_(iF) {} template Foam::faePatchField::faePatchField ( - const faePatchField& ptf, + const faePatchField& pfld, const DimensionedField& iF ) : - faePatchFieldBase(ptf), - Field(ptf), + faePatchFieldBase(pfld), + Field(pfld), internalField_(iF) {} diff --git a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H index e803f3b555..68faa35218 100644 --- a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H +++ b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2019-2024 OpenCFD Ltd. + Copyright (C) 2019-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -144,6 +144,12 @@ public: return Foam::fieldTypes::calculatedType; } + //- The type name for \c zeroValue patch fields + static const word& zeroValueType() noexcept + { + return Foam::fieldTypes::zeroValueType; + } + // Member Functions @@ -381,16 +387,29 @@ public: const faPatchFieldMapper& ); - //- Construct as copy - faePatchField(const faePatchField&); - - //- Construct as copy setting internal field reference + //- Copy construct onto new patch with specified value faePatchField ( - const faePatchField&, - const DimensionedField& + const faePatchField& pfld, + const faPatch& p, + const DimensionedField& iF, + const Type& value ); + //- Copy construct with internal field reference + faePatchField + ( + const faePatchField& pfld, + const DimensionedField& iF + ); + + //- Copy construct + faePatchField(const faePatchField& pfld) + : + faePatchField(pfld, pfld.internalField()) + {} + + //- Clone patch field with its own internal field reference virtual tmp> clone() const { diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 8a149485ce..87473b4cbb 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -138,6 +138,7 @@ $(basicFvPatchFields)/mixed/mixedFvPatchFields.C $(basicFvPatchFields)/sliced/slicedFvPatchFields.C $(basicFvPatchFields)/transform/transformFvPatchFields.C $(basicFvPatchFields)/zeroGradient/zeroGradientFvPatchFields.C +$(basicFvPatchFields)/zeroValue/zeroValueFvPatchFields.C constraintFvPatchFields = $(fvPatchFields)/constraint $(constraintFvPatchFields)/cyclic/cyclicFvPatchFields.C @@ -263,6 +264,7 @@ $(basicFvsPatchFields)/calculated/calculatedFvsPatchFields.C $(basicFvsPatchFields)/coupled/coupledFvsPatchFields.C $(basicFvsPatchFields)/fixedValue/fixedValueFvsPatchFields.C $(basicFvsPatchFields)/sliced/slicedFvsPatchFields.C +$(basicFvsPatchFields)/zeroValue/zeroValueFvsPatchFields.C constraintFvsPatchFields = $(fvsPatchFields)/constraint $(constraintFvsPatchFields)/cyclic/cyclicFvsPatchFields.C diff --git a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C index 7ce790c829..f9881ff81a 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2023 OpenCFD Ltd. + Copyright (C) 2023-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -92,21 +92,24 @@ Foam::fixedValueFvPatchField::fixedValueFvPatchField template Foam::fixedValueFvPatchField::fixedValueFvPatchField ( - const fixedValueFvPatchField& ptf, - const DimensionedField& iF + const fixedValueFvPatchField& pfld, + const fvPatch& p, + const DimensionedField& iF, + const Type& value ) : - fvPatchField(ptf, iF) + fvPatchField(pfld, p, iF, value) {} template Foam::fixedValueFvPatchField::fixedValueFvPatchField ( - const fixedValueFvPatchField& ptf + const fixedValueFvPatchField& pfld, + const DimensionedField& iF ) : - fixedValueFvPatchField(ptf, ptf.internalField()) + fvPatchField(pfld, iF) {} @@ -119,6 +122,7 @@ Foam::fixedValueFvPatchField::valueInternalCoeffs const tmp& ) const { + // No contribution from internal values return tmp>::New(this->size(), Foam::zero{}); } diff --git a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H index 7c2fa1bcc8..bd1beace6a 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2023 OpenCFD Ltd. + Copyright (C) 2023-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -131,19 +131,30 @@ public: const fvPatchFieldMapper& ); - //- Construct as copy + //- Construct onto a new patch with internal field reference + //- and specified value fixedValueFvPatchField ( - const fixedValueFvPatchField& + const fixedValueFvPatchField& pfld, + const fvPatch& p, + const DimensionedField& iF, + const Type& value ); - //- Construct as copy setting internal field reference + //- Copy construct with internal field reference fixedValueFvPatchField ( - const fixedValueFvPatchField&, - const DimensionedField& + const fixedValueFvPatchField& pfld, + const DimensionedField& iF ); + //- Copy construct + fixedValueFvPatchField(const fixedValueFvPatchField& pfld) + : + fixedValueFvPatchField(pfld, pfld.internalField()) + {} + + //- Return a clone virtual tmp> clone() const { @@ -199,6 +210,7 @@ public: // Member Operators + // Disable assignment operators virtual void operator=(const UList&) {} virtual void operator=(const fvPatchField&) {} diff --git a/src/finiteVolume/fields/fvPatchFields/basic/zeroValue/zeroValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/zeroValue/zeroValueFvPatchField.C new file mode 100644 index 0000000000..62a945a933 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/basic/zeroValue/zeroValueFvPatchField.C @@ -0,0 +1,136 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023-2025 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 . + +\*---------------------------------------------------------------------------*/ + +#include "zeroValueFvPatchField.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::zeroValueFvPatchField::zeroValueFvPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + // Field is zero + parent_bctype(p, iF, Type(Zero)) +{} + + +template +Foam::zeroValueFvPatchField::zeroValueFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + // Field is zero + parent_bctype(p, iF, Type(Zero)) +{ + fvPatchFieldBase::readDict(dict); +} + + +template +Foam::zeroValueFvPatchField::zeroValueFvPatchField +( + const zeroValueFvPatchField& pfld, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& +) +: + // Field is zero. No mapping + parent_bctype(pfld, p, iF, Type(Zero)) +{} + + +template +Foam::zeroValueFvPatchField::zeroValueFvPatchField +( + const zeroValueFvPatchField& pfld, + const DimensionedField& iF +) +: + // Field is zero + parent_bctype(pfld, pfld.patch(), iF, Type(Zero)) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::tmp> +Foam::zeroValueFvPatchField::valueInternalCoeffs +( + const tmp& +) const +{ + // No contribution from internal values + return tmp>::New(this->size(), Foam::zero{}); +} + + +template +Foam::tmp> +Foam::zeroValueFvPatchField::valueBoundaryCoeffs +( + const tmp& +) const +{ + // Patch field is zero + return tmp>::New(this->size(), Foam::zero{}); +} + + +template +Foam::tmp> +Foam::zeroValueFvPatchField::gradientInternalCoeffs() const +{ + return -pTraits::one*this->patch().deltaCoeffs(); +} + + +template +Foam::tmp> +Foam::zeroValueFvPatchField::gradientBoundaryCoeffs() const +{ + // Patch field is zero + return tmp>::New(this->size(), Foam::zero{}); +} + + +template +void Foam::zeroValueFvPatchField::write(Ostream& os) const +{ + fvPatchField::write(os); + // Without writeValueEntry() since the value == zero +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/basic/zeroValue/zeroValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/basic/zeroValue/zeroValueFvPatchField.H new file mode 100644 index 0000000000..4b4d209cb8 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/basic/zeroValue/zeroValueFvPatchField.H @@ -0,0 +1,226 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023-2025 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::zeroValueFvPatchField + +Group + grpGenericBoundaryConditions + +Description + Specifies a zero fixed value boundary condition. + +Usage + Example of the boundary condition specification: + \verbatim + + { + type zeroValue; + } + \endverbatim + +SourceFiles + zeroValueFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Foam_zeroValueFvPatchField_H +#define Foam_zeroValueFvPatchField_H + +#include "fixedValueFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class zeroValueFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template +class zeroValueFvPatchField +: + public fixedValueFvPatchField +{ + //- The parent boundary condition type + typedef fixedValueFvPatchField parent_bctype; + +public: + + //- Runtime type information + TypeName("zeroValue"); + + + // Constructors + + //- Construct from patch and internal field + zeroValueFvPatchField + ( + const fvPatch& p, + const DimensionedField& iF + ); + + //- Construct from patch, internal field and dictionary + zeroValueFvPatchField + ( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict + ); + + //- Copy construct onto a new patch (no mapping needed) + zeroValueFvPatchField + ( + const zeroValueFvPatchField& pfld, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& + ); + + //- Copy construct with internal field reference + zeroValueFvPatchField + ( + const zeroValueFvPatchField& pfld, + const DimensionedField& iF + ); + + //- Copy construct + zeroValueFvPatchField(const zeroValueFvPatchField& pfld) + : + zeroValueFvPatchField(pfld, pfld.internalField()) + {} + + + //- Construct and return a clone + virtual tmp> clone() const + { + return tmp> + ( + new zeroValueFvPatchField(*this) + ); + } + + //- Construct and return a clone setting internal field reference + virtual tmp> clone + ( + const DimensionedField& iF + ) const + { + return tmp> + ( + new zeroValueFvPatchField(*this, iF) + ); + } + + + // Member Functions + + //- True: this patch field fixes a value. + virtual bool fixesValue() const { return true; } + + //- False: this patch field is not altered by assignment. + virtual bool assignable() const { return false; } + + //- Write (without "value" entry) + virtual void write(Ostream& os) const; + + + // Evaluation Functions + + //- Return the matrix diagonal coefficients corresponding to the + //- evaluation of the value of this patchField with given weights + virtual tmp> valueInternalCoeffs + ( + const tmp& + ) const; + + //- Return the matrix source coefficients corresponding to the + //- evaluation of the value of this patchField with given weights + virtual tmp> valueBoundaryCoeffs + ( + const tmp& + ) const; + + //- Return the matrix diagonal coefficients corresponding to the + //- evaluation of the gradient of this patchField + virtual tmp> gradientInternalCoeffs() const; + + //- Return the matrix source coefficients corresponding to the + //- evaluation of the gradient of this patchField + virtual tmp> gradientBoundaryCoeffs() const; + + + // Member Operators + + // Disable assignment operators + virtual void operator=(const UList&) {} + + virtual void operator=(const fvPatchField&) {} + virtual void operator+=(const fvPatchField&) {} + virtual void operator-=(const fvPatchField&) {} + virtual void operator*=(const fvPatchField&) {} + virtual void operator/=(const fvPatchField&) {} + + virtual void operator+=(const Field&) {} + virtual void operator-=(const Field&) {} + + virtual void operator*=(const Field&) {} + virtual void operator/=(const Field&) {} + + virtual void operator=(const Type&) {} + virtual void operator+=(const Type&) {} + virtual void operator-=(const Type&) {} + virtual void operator*=(const scalar) {} + virtual void operator/=(const scalar) {} + + + // Disable forced assignment operators + virtual void operator==(const fvPatchField&) {} + virtual void operator==(const Field&) {} + virtual void operator==(const Type&) {} + + // Prevent automatic comparison rewriting (c++20) + bool operator!=(const fvPatchField&) const = delete; + bool operator!=(const Field&) const = delete; + bool operator!=(const Type&) const = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "zeroValueFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/basic/zeroValue/zeroValueFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/basic/zeroValue/zeroValueFvPatchFields.C new file mode 100644 index 0000000000..3ca8ded009 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/basic/zeroValue/zeroValueFvPatchFields.C @@ -0,0 +1,39 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023 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 . + +\*---------------------------------------------------------------------------*/ + +#include "zeroValueFvPatchFields.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchFields(zeroValue); +} + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/basic/zeroValue/zeroValueFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/basic/zeroValue/zeroValueFvPatchFields.H new file mode 100644 index 0000000000..4a3df6eeee --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/basic/zeroValue/zeroValueFvPatchFields.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef Foam_zeroValueFvPatchFields_H +#define Foam_zeroValueFvPatchFields_H + +#include "zeroValueFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(zeroValue); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.C index 039c126276..a0f3c62678 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.C @@ -37,7 +37,8 @@ Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField const DimensionedField& iF ) : - fixedValueFvPatchVectorField(p, iF, Zero) + // Field is zero + parent_bctype(p, iF, Zero) {} @@ -48,7 +49,8 @@ Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField const dictionary& dict ) : - fixedValueFvPatchVectorField(p, iF, Zero) + // Field is zero + parent_bctype(p, iF, Zero) { fvPatchFieldBase::readDict(dict); } @@ -56,32 +58,25 @@ Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField ( - const noSlipFvPatchVectorField& ptf, + const noSlipFvPatchVectorField& pfld, const fvPatch& p, const DimensionedField& iF, - const fvPatchFieldMapper& mapper + const fvPatchFieldMapper& ) : - fixedValueFvPatchVectorField(p, iF, Zero) + // Field is zero. No mapping + parent_bctype(pfld, p, iF, Zero) {} Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField ( - const noSlipFvPatchVectorField& mwvpvf -) -: - fixedValueFvPatchVectorField(mwvpvf) -{} - - -Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField -( - const noSlipFvPatchVectorField& mwvpvf, + const noSlipFvPatchVectorField& pfld, const DimensionedField& iF ) : - fixedValueFvPatchVectorField(mwvpvf, iF) + // Field is zero + parent_bctype(pfld, pfld.patch(), iF, Zero) {} @@ -90,6 +85,7 @@ Foam::noSlipFvPatchVectorField::noSlipFvPatchVectorField void Foam::noSlipFvPatchVectorField::write(Ostream& os) const { fvPatchField::write(os); + // Without writeValueEntry() since the value == zero } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.H index 3590a2aeb9..7fa0de9618 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/noSlip/noSlipFvPatchVectorField.H @@ -30,27 +30,28 @@ Group grpWallBoundaryConditions Description - This boundary condition fixes the velocity to zero at walls. + This boundary condition fixes the velocity to zero (eg, at walls). Usage Example of the boundary condition specification: \verbatim { - type noSlip; + type noSlip; } \endverbatim See also Foam::fixedValueFvPatchVectorField + Foam::zeroValueFvPatchVectorField SourceFiles noSlipFvPatchVectorField.C \*---------------------------------------------------------------------------*/ -#ifndef noSlipFvPatchVectorField_H -#define noSlipFvPatchVectorField_H +#ifndef Foam_noSlipFvPatchVectorField_H +#define Foam_noSlipFvPatchVectorField_H #include "fixedValueFvPatchFields.H" @@ -60,13 +61,15 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class noSlipFvPatchVectorField Declaration + Class noSlipFvPatchVectorField Declaration \*---------------------------------------------------------------------------*/ class noSlipFvPatchVectorField : public fixedValueFvPatchVectorField { + //- The parent boundary condition type + typedef fixedValueFvPatchVectorField parent_bctype; public: @@ -92,7 +95,7 @@ public: ); //- Construct by mapping given noSlipFvPatchVectorField - // onto a new patch + //- onto a new patch noSlipFvPatchVectorField ( const noSlipFvPatchVectorField&, @@ -101,18 +104,19 @@ public: const fvPatchFieldMapper& ); - //- Construct as copy + //- Copy construct with internal field reference noSlipFvPatchVectorField ( - const noSlipFvPatchVectorField& + const noSlipFvPatchVectorField& pfld, + const DimensionedField& iF ); - //- Construct as copy setting internal field reference - noSlipFvPatchVectorField - ( - const noSlipFvPatchVectorField&, - const DimensionedField& - ); + //- Copy construct + noSlipFvPatchVectorField(const noSlipFvPatchVectorField& pfld) + : + noSlipFvPatchVectorField(pfld, pfld.internalField()) + {} + //- Return a clone virtual tmp> clone() const @@ -130,7 +134,7 @@ public: } - // Member functions + // Member Functions //- Write virtual void write(Ostream&) const; diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C index 542f52d579..97dfcf2cad 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C @@ -187,12 +187,15 @@ Foam::fvPatchField::fvPatchField template Foam::fvPatchField::fvPatchField ( - const fvPatchField& ptf + const fvPatchField& pfld, + const fvPatch& p, + const DimensionedField& iF, + const Type& value ) : - fvPatchFieldBase(ptf), - Field(ptf), - internalField_(ptf.internalField_) + fvPatchFieldBase(pfld, p), + Field(p.size(), value), + internalField_(iF) {} diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H index 8e42c3617a..26aca3d936 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H @@ -169,6 +169,12 @@ public: return Foam::fieldTypes::zeroGradientType; } + //- The type name for \c zeroValue patch fields + static const word& zeroValueType() noexcept + { + return Foam::fieldTypes::zeroValueType; + } + // Member Functions @@ -455,16 +461,30 @@ public: const fvPatchFieldMapper& ); - //- Construct as copy - fvPatchField(const fvPatchField&); - - //- Construct as copy setting internal field reference + //- Copy construct onto a new patch with internal field reference + //- and specified value fvPatchField ( - const fvPatchField&, - const DimensionedField& + const fvPatchField& pfld, + const fvPatch& p, + const DimensionedField& iF, + const Type& value ); + //- Copy construct with internal field reference + fvPatchField + ( + const fvPatchField& pfld, + const DimensionedField& iF + ); + + //- Copy construct + fvPatchField(const fvPatchField& pfld) + : + fvPatchField(pfld, pfld.internalField()) + {} + + //- Clone patch field with its own internal field reference virtual tmp> clone() const { @@ -673,7 +693,7 @@ public: // evaluation of the value of this patchField with given weights virtual tmp> valueInternalCoeffs ( - const tmp>& + const tmp& ) const { NotImplemented; @@ -684,7 +704,7 @@ public: // evaluation of the value of this patchField with given weights virtual tmp> valueBoundaryCoeffs ( - const tmp>& + const tmp& ) const { NotImplemented; diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C index 2d061f7ced..a2207cf9a0 100644 --- a/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2024 OpenCFD Ltd. + Copyright (C) 2024-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -82,21 +82,24 @@ Foam::fixedValueFvsPatchField::fixedValueFvsPatchField template Foam::fixedValueFvsPatchField::fixedValueFvsPatchField ( - const fixedValueFvsPatchField& ptf, - const DimensionedField& iF + const fixedValueFvsPatchField& pfld, + const fvPatch& p, + const DimensionedField& iF, + const Type& value ) : - fvsPatchField(ptf, iF) + fvsPatchField(pfld, p, iF, value) {} template Foam::fixedValueFvsPatchField::fixedValueFvsPatchField ( - const fixedValueFvsPatchField& ptf + const fixedValueFvsPatchField& pfld, + const DimensionedField& iF ) : - fixedValueFvsPatchField(ptf, ptf.internalField()) + fvsPatchField(pfld, iF) {} diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.H index 300caa3b11..fe303ce995 100644 --- a/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.H @@ -114,18 +114,30 @@ public: const fvPatchFieldMapper& ); - //- Construct as copy + //- Copy construct onto a new patch with internal field reference + //- and specified value fixedValueFvsPatchField ( - const fixedValueFvsPatchField& + const fixedValueFvsPatchField& pfld, + const fvPatch& p, + const DimensionedField& iF, + const Type& value ); + //- Copy construct with internal field reference fixedValueFvsPatchField ( - const fixedValueFvsPatchField&, - const DimensionedField& + const fixedValueFvsPatchField& pfld, + const DimensionedField& iF ); + //- Copy construct + fixedValueFvsPatchField(const fixedValueFvsPatchField& pfld) + : + fixedValueFvsPatchField(pfld, pfld.internalField()) + {} + + //- Return clone virtual tmp> clone() const { diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/zeroValue/zeroValueFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/basic/zeroValue/zeroValueFvsPatchField.C new file mode 100644 index 0000000000..58bb16ffe5 --- /dev/null +++ b/src/finiteVolume/fields/fvsPatchFields/basic/zeroValue/zeroValueFvsPatchField.C @@ -0,0 +1,136 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023-2025 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 . + +\*---------------------------------------------------------------------------*/ + +#include "zeroValueFvsPatchField.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::zeroValueFvsPatchField::zeroValueFvsPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + // Field is zero + parent_bctype(p, iF, Type(Zero)) +{} + + +template +Foam::zeroValueFvsPatchField::zeroValueFvsPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + // Field is zero + parent_bctype(p, iF, Type(Zero)) +{ + fvsPatchFieldBase::readDict(dict); +} + + +template +Foam::zeroValueFvsPatchField::zeroValueFvsPatchField +( + const zeroValueFvsPatchField& pfld, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& +) +: + // Field is zero. No mapping + parent_bctype(pfld, p, iF, Type(Zero)) +{} + + +template +Foam::zeroValueFvsPatchField::zeroValueFvsPatchField +( + const zeroValueFvsPatchField& pfld, + const DimensionedField& iF +) +: + // Field is zero + parent_bctype(pfld, pfld.patch(), iF, Type(Zero)) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::tmp> +Foam::zeroValueFvsPatchField::valueInternalCoeffs +( + const tmp& +) const +{ + // No contribution from internal values + return tmp>::New(this->size(), Foam::zero{}); +} + + +template +Foam::tmp> +Foam::zeroValueFvsPatchField::valueBoundaryCoeffs +( + const tmp& +) const +{ + // Patch field is zero + return tmp>::New(this->size(), Foam::zero{}); +} + + +template +Foam::tmp> +Foam::zeroValueFvsPatchField::gradientInternalCoeffs() const +{ + return -pTraits::one*this->patch().deltaCoeffs(); +} + + +template +Foam::tmp> +Foam::zeroValueFvsPatchField::gradientBoundaryCoeffs() const +{ + // Patch field is zero + return tmp>::New(this->size(), Foam::zero{}); +} + + +template +void Foam::zeroValueFvsPatchField::write(Ostream& os) const +{ + fvsPatchField::write(os); + // Without writeValueEntry() since the value == zero +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/zeroValue/zeroValueFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/basic/zeroValue/zeroValueFvsPatchField.H new file mode 100644 index 0000000000..1a4950f069 --- /dev/null +++ b/src/finiteVolume/fields/fvsPatchFields/basic/zeroValue/zeroValueFvsPatchField.H @@ -0,0 +1,217 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023-2025 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::zeroValueFvsPatchField + +Description + Specifies a zero fixed value boundary condition. + +Usage + Example of the boundary condition specification: + \verbatim + + { + type zeroValue; + } + \endverbatim + +SourceFiles + zeroValueFvsPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Foam_zeroValueFvsPatchField_H +#define Foam_zeroValueFvsPatchField_H + +#include "fixedValueFvsPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class zeroValueFvsPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template +class zeroValueFvsPatchField +: + public fixedValueFvsPatchField +{ + //- The parent boundary condition type + typedef fixedValueFvsPatchField parent_bctype; + +public: + + //- Runtime type information + TypeName("zeroValue"); + + + // Constructors + + //- Construct from patch and internal field + zeroValueFvsPatchField + ( + const fvPatch& p, + const DimensionedField& iF + ); + + //- Construct from patch, internal field and dictionary + zeroValueFvsPatchField + ( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict + ); + + //- Copy construct onto a new patch (no mapping needed) + zeroValueFvsPatchField + ( + const zeroValueFvsPatchField& pfld, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& + ); + + //- Copy construct with internal field reference + zeroValueFvsPatchField + ( + const zeroValueFvsPatchField& pfld, + const DimensionedField& iF + ); + + //- Copy construct + zeroValueFvsPatchField(const zeroValueFvsPatchField& pfld) + : + zeroValueFvsPatchField(pfld, pfld.internalField()) + {} + + + //- Return clone + virtual tmp> clone() const + { + return fvsPatchField::Clone(*this); + } + + //- Clone with an internal field reference + virtual tmp> clone + ( + const DimensionedField& iF + ) const + { + return fvsPatchField::Clone(*this, iF); + } + + + // Member Functions + + //- True: this patch field fixes a value. + virtual bool fixesValue() const { return true; } + + //- False: this patch field is not altered by assignment. + virtual bool assignable() const { return false; } + + //- Write (without "value" entry) + virtual void write(Ostream& os) const; + + + // Evaluation Functions + + //- Return the matrix diagonal coefficients corresponding to the + //- evaluation of the value of this patchField with given weights + virtual tmp> valueInternalCoeffs + ( + const tmp& + ) const; + + //- Return the matrix source coefficients corresponding to the + //- evaluation of the value of this patchField with given weights + virtual tmp> valueBoundaryCoeffs + ( + const tmp& + ) const; + + //- Return the matrix diagonal coefficients corresponding to the + //- evaluation of the gradient of this patchField + virtual tmp> gradientInternalCoeffs() const; + + //- Return the matrix source coefficients corresponding to the + //- evaluation of the gradient of this patchField + virtual tmp> gradientBoundaryCoeffs() const; + + + // Member Operators + + // Disable assignment operators + virtual void operator=(const UList&) {} + + virtual void operator=(const fvsPatchField&) {} + virtual void operator+=(const fvsPatchField&) {} + virtual void operator-=(const fvsPatchField&) {} + virtual void operator*=(const fvsPatchField&) {} + virtual void operator/=(const fvsPatchField&) {} + + virtual void operator+=(const Field&) {} + virtual void operator-=(const Field&) {} + + virtual void operator*=(const Field&) {} + virtual void operator/=(const Field&) {} + + virtual void operator=(const Type&) {} + virtual void operator+=(const Type&) {} + virtual void operator-=(const Type&) {} + virtual void operator*=(const scalar) {} + virtual void operator/=(const scalar) {} + + + // Disable forced assignment operators + virtual void operator==(const fvsPatchField&) {} + virtual void operator==(const Field&) {} + virtual void operator==(const Type&) {} + + // Prevent automatic comparison rewriting (c++20) + bool operator!=(const fvPatchField&) const = delete; + bool operator!=(const Field&) const = delete; + bool operator!=(const Type&) const = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "zeroValueFvsPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/zeroValue/zeroValueFvsPatchFields.C b/src/finiteVolume/fields/fvsPatchFields/basic/zeroValue/zeroValueFvsPatchFields.C new file mode 100644 index 0000000000..5c0dd707d8 --- /dev/null +++ b/src/finiteVolume/fields/fvsPatchFields/basic/zeroValue/zeroValueFvsPatchFields.C @@ -0,0 +1,39 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023 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 . + +\*---------------------------------------------------------------------------*/ + +#include "zeroValueFvsPatchFields.H" +#include "surfaceFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + makeFvsPatchFields(zeroValue); +} + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/zeroValue/zeroValueFvsPatchFields.H b/src/finiteVolume/fields/fvsPatchFields/basic/zeroValue/zeroValueFvsPatchFields.H new file mode 100644 index 0000000000..3ee36822f9 --- /dev/null +++ b/src/finiteVolume/fields/fvsPatchFields/basic/zeroValue/zeroValueFvsPatchFields.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef Foam_zeroValueFvsPatchFields_H +#define Foam_zeroValueFvsPatchFields_H + +#include "zeroValueFvsPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makeFvsPatchTypeFieldTypedefs(zeroValue); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C index 027b488214..1f23b25347 100644 --- a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C @@ -155,23 +155,29 @@ Foam::fvsPatchField::fvsPatchField template -Foam::fvsPatchField::fvsPatchField(const fvsPatchField& ptf) +Foam::fvsPatchField::fvsPatchField +( + const fvsPatchField& pfld, + const fvPatch& p, + const DimensionedField& iF, + const Type& value +) : - fvsPatchFieldBase(ptf), - Field(ptf), - internalField_(ptf.internalField_) + fvsPatchFieldBase(pfld, p), + Field(p.size(), value), + internalField_(iF) {} template Foam::fvsPatchField::fvsPatchField ( - const fvsPatchField& ptf, + const fvsPatchField& pfld, const DimensionedField& iF ) : - fvsPatchFieldBase(ptf), - Field(ptf), + fvsPatchFieldBase(pfld), + Field(pfld), internalField_(iF) {} diff --git a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H index 4361692182..6da8ed5b43 100644 --- a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H @@ -139,6 +139,12 @@ public: return Foam::fieldTypes::calculatedType; } + //- The type name for \c zeroValue patch fields + static const word& zeroValueType() noexcept + { + return Foam::fieldTypes::zeroValueType; + } + // Member Functions @@ -398,16 +404,30 @@ public: const fvPatchFieldMapper& ); - //- Construct as copy - fvsPatchField(const fvsPatchField&); + //- Construct onto new patch with internal field reference + //- and specified value + fvsPatchField + ( + const fvsPatchField& pfld, + const fvPatch& p, + const DimensionedField& iF, + const Type& value + ); - //- Construct as copy setting internal field reference + //- Copy construct with internal field reference fvsPatchField ( const fvsPatchField&, const DimensionedField& ); + //- Copy construct + fvsPatchField(const fvsPatchField& pfld) + : + fvsPatchField(pfld, pfld.internalField()) + {} + + //- Clone patch field with its own internal field reference virtual tmp> clone() const { @@ -541,42 +561,40 @@ public: ); - // Evaluation Functions + // Evaluation Functions - //- Initialise the evaluation of the patch field - virtual void initEvaluate - ( - const Pstream::commsTypes commsType = - Pstream::commsTypes::buffered - ) - {} + //- Initialise the evaluation of the patch field + virtual void initEvaluate + ( + const Pstream::commsTypes commsType = Pstream::commsTypes::buffered + ) + {} - //- Evaluate the patch field, sets Updated to false - virtual void evaluate - ( - const Pstream::commsTypes commsType = - Pstream::commsTypes::buffered - ) - {} + //- Evaluate the patch field, sets Updated to false + virtual void evaluate + ( + const Pstream::commsTypes commsType = Pstream::commsTypes::buffered + ) + {} - //- Initialise the evaluation of the patch field after a local - // operation - virtual void initEvaluateLocal - ( - const Pstream::commsTypes commsType = - Pstream::commsTypes::buffered - ) - {} + //- Initialise the evaluation of the patch field after a local + // operation + virtual void initEvaluateLocal + ( + const Pstream::commsTypes commsType = Pstream::commsTypes::buffered + ) + {} - //- Evaluate the patch field after a local operation (e.g. *=) - virtual void evaluateLocal - ( - const Pstream::commsTypes commsType = - Pstream::commsTypes::buffered - ) - {} + //- Evaluate the patch field after a local operation (e.g. *=) + virtual void evaluateLocal + ( + const Pstream::commsTypes commsType = Pstream::commsTypes::buffered + ) + {} + // Other + //- Write the patch "type" virtual void write(Ostream& os) const; diff --git a/src/mesh/snappyHexMesh/Make/files b/src/mesh/snappyHexMesh/Make/files index 50a44505e8..0a4d7f6b2e 100644 --- a/src/mesh/snappyHexMesh/Make/files +++ b/src/mesh/snappyHexMesh/Make/files @@ -33,7 +33,6 @@ externalDisplacementMeshMover/externalDisplacementMeshMover.C externalDisplacementMeshMover/medialAxisMeshMover.C externalDisplacementMeshMover/displacementMotionSolverMeshMover.C /* externalDisplacementMeshMover/pointSmoothingMeshMover.C */ -externalDisplacementMeshMover/zeroFixedValue/zeroFixedValuePointPatchFields.C externalDisplacementMeshMover/fieldSmoother/fieldSmoother.C LIB = $(FOAM_LIBBIN)/libsnappyHexMesh diff --git a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/externalDisplacementMeshMover.C b/src/mesh/snappyHexMesh/externalDisplacementMeshMover/externalDisplacementMeshMover.C index d11bc4d486..2123aeb2e6 100644 --- a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/externalDisplacementMeshMover.C +++ b/src/mesh/snappyHexMesh/externalDisplacementMeshMover/externalDisplacementMeshMover.C @@ -28,7 +28,7 @@ License #include "externalDisplacementMeshMover.H" #include "mapPolyMesh.H" -#include "zeroFixedValuePointPatchFields.H" +#include "zeroValuePointPatchFields.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -50,20 +50,16 @@ Foam::labelList Foam::externalDisplacementMeshMover::getFixedValueBCs forAll(field.boundaryField(), patchI) { - const pointPatchField& patchField = - field.boundaryField()[patchI]; + const auto& patchField = field.boundaryField()[patchI]; - if (isA>(patchField)) + if (isA>(patchField)) { - if (isA>(patchField)) - { - // Special condition of fixed boundary condition. Does not - // get adapted - } - else - { - adaptPatchIDs.append(patchI); - } + // Special condition of fixed boundary condition. Does not + // get adapted + } + else if (isA>(patchField)) + { + adaptPatchIDs.append(patchI); } } diff --git a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C b/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C index 295013ecba..78b1425aae 100644 --- a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C +++ b/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C @@ -36,7 +36,7 @@ License #include "PatchTools.H" #include "OBJstream.H" #include "PointData.H" -#include "zeroFixedValuePointPatchFields.H" +#include "zeroValuePointPatchFields.H" #include "pointSet.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // diff --git a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.H b/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.H index c2a91aec22..8e74a0aa2e 100644 --- a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.H +++ b/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.H @@ -34,7 +34,7 @@ Description This fraction is then used to scale the motion. Use - fixedValue on all moving patches - - zeroFixedValue on stationary patches + - zeroValue on stationary patches - slip on all slipping patches Note that the fixedValue boundary conditions might be changed by this solver to enforce consistency and a valid resulting mesh. diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C index ff4a61c5b1..65b955d035 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C @@ -53,7 +53,7 @@ Description #include "PatchTools.H" #include "slipPointPatchFields.H" #include "fixedValuePointPatchFields.H" -#include "zeroFixedValuePointPatchFields.H" +#include "zeroValuePointPatchFields.H" #include "calculatedPointPatchFields.H" #include "cyclicSlipPointPatchFields.H" #include "fixedValueFvPatchFields.H" @@ -1148,8 +1148,7 @@ Foam::snappyLayerDriver::makeLayerDisplacementField // >0 layers: fixedValue which gets adapted if (numLayers[patchi] == 0) { - patchFieldTypes[patchi] = - zeroFixedValuePointPatchVectorField::typeName; + patchFieldTypes[patchi] = zeroValuePointPatchVectorField::typeName; } else if (numLayers[patchi] > 0) {