From 8a8b5db977c384db56696eb96cb630117b86cd71 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 18 Apr 2024 12:55:40 +0200 Subject: [PATCH 1/2] BUG: fvsPatchFields reading/writing the "value" entry (fixes #3144) - manual revert for 44d0fbd594a9. Unless required for post-processing the "value" entry should not written if it is not mandatory for reading. This is especially crucial with an 'empty' patch field where the field (size 0) has a different size from the patch. - the changes made align fvsPatchField behaviour with fvPatchField --- .../fixedValue/fixedValuePointPatchField.H | 6 ++-- .../basic/value/valuePointPatchField.H | 4 +-- .../porousBafflePressureFvPatchField.C | 6 ++-- .../porousBafflePressureFvPatchField.H | 2 +- .../basic/sliced/slicedFaPatchField.H | 7 ++-- .../constraint/empty/emptyFaPatchField.C | 19 +++++----- .../constraint/empty/emptyFaPatchField.H | 7 ++-- .../clampedPlate/clampedPlateFaPatchField.H | 2 +- .../edgeNormalFixedValueFaPatchVectorField.H | 2 +- .../fixedValueOutflowFaPatchField.H | 4 +-- .../inletOutlet/inletOutletFaPatchField.H | 2 +- .../outletInlet/outletInletFaPatchField.H | 2 +- ...timeVaryingUniformFixedValueFaPatchField.H | 2 +- .../uniformFixedGradientFaPatchField.H | 4 +-- .../uniformFixedValueFaPatchField.H | 2 +- .../uniformMixed/uniformMixedFaPatchField.H | 2 +- .../constraint/empty/emptyFaePatchField.C | 19 +++++----- .../constraint/empty/emptyFaePatchField.H | 3 +- .../basicSymmetry/basicSymmetryFvPatchField.H | 11 +++--- .../basic/calculated/calculatedFvPatchField.H | 13 ++++--- .../basic/coupled/coupledFvPatchField.H | 11 +++--- .../basic/fixedValue/fixedValueFvPatchField.C | 10 +++--- .../basic/fixedValue/fixedValueFvPatchField.H | 13 ++++--- .../basic/transform/transformFvPatchField.H | 11 +++--- .../constraint/cyclic/cyclicFvPatchField.C | 5 +-- .../constraint/cyclic/cyclicFvPatchField.H | 8 +++-- .../cyclicSlip/cyclicSlipFvPatchField.C | 2 +- .../cyclicSlip/cyclicSlipFvPatchField.H | 10 +++--- .../constraint/empty/emptyFvPatchField.C | 25 +++++++------ .../constraint/empty/emptyFvPatchField.H | 7 ++-- .../jumpCyclic/jumpCyclicFvPatchField.C | 11 +++--- .../jumpCyclic/jumpCyclicFvPatchField.H | 12 ++++--- .../nonuniformTransformCyclicFvPatchField.C | 2 +- .../nonuniformTransformCyclicFvPatchField.H | 11 +++--- .../processor/processorFvPatchField.C | 1 - .../processorCyclicFvPatchField.C | 7 ---- .../processorCyclicFvPatchField.H | 6 ++-- .../symmetry/symmetryFvPatchField.H | 1 - .../constraint/wedge/wedgeFvPatchField.C | 18 +++++----- .../constraint/wedge/wedgeFvPatchField.H | 12 +++++-- .../derived/fan/fanFvPatchField.C | 2 +- .../derived/fixedJump/fixedJumpFvPatchField.C | 8 ++--- .../derived/fixedJump/fixedJumpFvPatchField.H | 2 +- .../fixedNormalSlipFvPatchField.C | 9 +++-- .../fixedNormalSlipFvPatchField.H | 9 +++-- .../partialSlip/partialSlipFvPatchField.C | 25 +++++++------ .../partialSlip/partialSlipFvPatchField.H | 18 ++++++---- .../uniformJump/uniformJumpFvPatchField.C | 6 ++-- .../uniformJump/uniformJumpFvPatchField.H | 2 +- .../fvPatchFields/fvPatchField/fvPatchField.H | 4 +-- .../calculated/calculatedFvsPatchField.C | 12 ++++++- .../calculated/calculatedFvsPatchField.H | 24 ++++++++++++- .../basic/coupled/coupledFvsPatchField.C | 16 +++++++-- .../basic/coupled/coupledFvsPatchField.H | 31 ++++++++-------- .../fixedValue/fixedValueFvsPatchField.C | 22 ++++++++---- .../fixedValue/fixedValueFvsPatchField.H | 35 +++++++++++++++---- .../basic/sliced/slicedFvsPatchField.C | 12 ++++++- .../basic/sliced/slicedFvsPatchField.H | 9 +++-- .../constraint/cyclic/cyclicFvsPatchField.H | 25 +++++++++---- .../cyclicACMI/cyclicACMIFvsPatchField.C | 2 +- .../cyclicACMI/cyclicACMIFvsPatchField.H | 9 +++-- .../cyclicAMI/cyclicAMIFvsPatchField.H | 11 ++++-- .../constraint/empty/emptyFvsPatchField.C | 25 +++++++------ .../constraint/empty/emptyFvsPatchField.H | 21 ++++++++--- .../processor/processorFvsPatchField.C | 7 ---- .../processor/processorFvsPatchField.H | 29 ++++++++++----- .../processorCyclicFvsPatchField.C | 7 ---- .../processorCyclicFvsPatchField.H | 23 ++++++------ .../symmetry/symmetryFvsPatchField.C | 23 ++++++------ .../symmetry/symmetryFvsPatchField.H | 20 ++++++++--- .../symmetryPlaneFvsPatchField.C | 23 ++++++------ .../symmetryPlaneFvsPatchField.H | 24 +++++++++---- .../constraint/wedge/wedgeFvsPatchField.C | 23 ++++++------ .../constraint/wedge/wedgeFvsPatchField.H | 23 +++++++++--- .../fvsPatchField/fvsPatchField.C | 1 - .../fvsPatchField/fvsPatchField.H | 6 ++-- ...specularRadiationMixedFvPatchScalarField.C | 2 +- 77 files changed, 525 insertions(+), 327 deletions(-) diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.H index c325c85529..e8f269edbb 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/basic/fixedValue/fixedValuePointPatchField.H @@ -30,6 +30,8 @@ Class Description A FixedValue boundary condition for pointField. + The "value" entry is normally MUST_READ. + SourceFiles fixedValuePointPatchField.C @@ -92,13 +94,13 @@ public: const pointPatch& p, const DimensionedField& iF, const dictionary& dict, - const bool valueReqd + const bool needValue ) : fixedValuePointPatchField ( p, iF, dict, - (valueReqd? IOobjectOption::MUST_READ : IOobjectOption::NO_READ) + (needValue? IOobjectOption::MUST_READ : IOobjectOption::NO_READ) ) {} diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.H index 377be79930..a4f7c2b205 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.H @@ -123,13 +123,13 @@ public: const pointPatch& p, const DimensionedField& iF, const dictionary& dict, - const bool valueReqd + const bool needValue ) : valuePointPatchField ( p, iF, dict, - (valueReqd? IOobjectOption::MUST_READ : IOobjectOption::NO_READ) + (needValue? IOobjectOption::MUST_READ : IOobjectOption::NO_READ) ) {} diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C index da66b10349..46336accf7 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C @@ -54,10 +54,10 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField const fvPatch& p, const DimensionedField& iF, const dictionary& dict, - const bool valueRequired + const bool needValue ) : - fixedJumpFvPatchField(p, iF, dict, false), + fixedJumpFvPatchField(p, iF, dict, false), // needValue = false phiName_(dict.getOrDefault("phi", "phi")), rhoName_(dict.getOrDefault("rho", "rho")), D_(Function1::New("D", dict, &db())), @@ -65,7 +65,7 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField length_(dict.get("length")), uniformJump_(dict.getOrDefault("uniformJump", false)) { - if (valueRequired) + if (needValue) { if (!this->readValueEntry(dict)) { diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.H index e99ee74e9a..ad9c2c60cd 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.H @@ -163,7 +163,7 @@ public: const fvPatch&, const DimensionedField&, const dictionary&, - const bool valueRequired = true + const bool needValue = true ); //- Construct by mapping given porousBafflePressureFvPatchField diff --git a/src/finiteArea/fields/faPatchFields/basic/sliced/slicedFaPatchField.H b/src/finiteArea/fields/faPatchFields/basic/sliced/slicedFaPatchField.H index dcee956514..3d31ef2ebe 100644 --- a/src/finiteArea/fields/faPatchFields/basic/sliced/slicedFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/basic/sliced/slicedFaPatchField.H @@ -95,7 +95,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- Not implemented slicedFaPatchField ( const faPatch&, @@ -103,8 +104,8 @@ public: const dictionary& ); - //- Construct by mapping the given sliced patch field - //- onto a new patch + //- Construct by mapping the given patch field onto a new patch. + //- Not implemented slicedFaPatchField ( const slicedFaPatchField&, diff --git a/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.C b/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.C index b7cc020fe8..daeae4a111 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.C @@ -38,7 +38,7 @@ Foam::emptyFaPatchField::emptyFaPatchField const DimensionedField& iF ) : - faPatchField(p, iF, Field()) + faPatchField(p, iF, Field()) // zero-sized patch field {} @@ -51,7 +51,7 @@ Foam::emptyFaPatchField::emptyFaPatchField const faPatchFieldMapper& ) : - faPatchField(p, iF, Field()) + faPatchField(p, iF, Field()) // zero-sized patch field { if (!isType(p)) { @@ -74,8 +74,11 @@ Foam::emptyFaPatchField::emptyFaPatchField const dictionary& dict ) : - faPatchField(p, iF, Field()) + faPatchField(p, iF, Field()) // zero-sized patch field { + // Empty means empty, so no patchType override + // with faPatchFieldBase::readDict(dict); + if (!isA(p)) { FatalIOErrorInFunction(dict) @@ -92,21 +95,21 @@ Foam::emptyFaPatchField::emptyFaPatchField template Foam::emptyFaPatchField::emptyFaPatchField ( - const emptyFaPatchField& ptf + const emptyFaPatchField& ptf, + const DimensionedField& iF ) : - faPatchField(ptf.patch(), ptf.internalField(), Field()) + faPatchField(ptf.patch(), iF, Field()) // zero-sized {} template Foam::emptyFaPatchField::emptyFaPatchField ( - const emptyFaPatchField& ptf, - const DimensionedField& iF + const emptyFaPatchField& ptf ) : - faPatchField(ptf.patch(), iF, Field()) + emptyFaPatchField(ptf, ptf.internalField()) {} diff --git a/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.H b/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.H index de754592be..ef6b2d9e36 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.H @@ -38,8 +38,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef emptyFaPatchField_H -#define emptyFaPatchField_H +#ifndef Foam_emptyFaPatchField_H +#define Foam_emptyFaPatchField_H #include "faPatchField.H" #include "emptyFaPatch.H" @@ -74,7 +74,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is NO_READ. emptyFaPatchField ( const faPatch&, diff --git a/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H index 4cb191c158..ca38463e02 100644 --- a/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H @@ -183,7 +183,7 @@ public: // IO - //- Write + //- Write includes "value" entry virtual void write(Ostream&) const; }; diff --git a/src/finiteArea/fields/faPatchFields/derived/edgeNormalFixedValue/edgeNormalFixedValueFaPatchVectorField.H b/src/finiteArea/fields/faPatchFields/derived/edgeNormalFixedValue/edgeNormalFixedValueFaPatchVectorField.H index 8a6c8dffb9..8c01ccf621 100644 --- a/src/finiteArea/fields/faPatchFields/derived/edgeNormalFixedValue/edgeNormalFixedValueFaPatchVectorField.H +++ b/src/finiteArea/fields/faPatchFields/derived/edgeNormalFixedValue/edgeNormalFixedValueFaPatchVectorField.H @@ -159,7 +159,7 @@ public: //- Update the coefficients associated with the patch field virtual void updateCoeffs(); - //- Write + //- Write includes "value" entry virtual void write(Ostream&) const; }; diff --git a/src/finiteArea/fields/faPatchFields/derived/fixedValueOutflow/fixedValueOutflowFaPatchField.H b/src/finiteArea/fields/faPatchFields/derived/fixedValueOutflow/fixedValueOutflowFaPatchField.H index 80b1522c26..ef3eb57580 100644 --- a/src/finiteArea/fields/faPatchFields/derived/fixedValueOutflow/fixedValueOutflowFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/derived/fixedValueOutflow/fixedValueOutflowFaPatchField.H @@ -150,11 +150,11 @@ public: virtual tmp> gradientBoundaryCoeffs() const; - //- Write + //- Write includes "value" entry virtual void write(Ostream&) const; - // Member operators + // Member Operators virtual void operator=(const UList&) {} diff --git a/src/finiteArea/fields/faPatchFields/derived/inletOutlet/inletOutletFaPatchField.H b/src/finiteArea/fields/faPatchFields/derived/inletOutlet/inletOutletFaPatchField.H index 02cb6831c7..0464beaa09 100644 --- a/src/finiteArea/fields/faPatchFields/derived/inletOutlet/inletOutletFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/derived/inletOutlet/inletOutletFaPatchField.H @@ -168,7 +168,7 @@ public: //- Update the coefficients associated with the patch field virtual void updateCoeffs(); - //- Write + //- Write includes "value" entry virtual void write(Ostream&) const; }; diff --git a/src/finiteArea/fields/faPatchFields/derived/outletInlet/outletInletFaPatchField.H b/src/finiteArea/fields/faPatchFields/derived/outletInlet/outletInletFaPatchField.H index e46a1d25b2..922f27e39b 100644 --- a/src/finiteArea/fields/faPatchFields/derived/outletInlet/outletInletFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/derived/outletInlet/outletInletFaPatchField.H @@ -163,7 +163,7 @@ public: //- Update the coefficients associated with the patch field virtual void updateCoeffs(); - //- Write + //- Write includes "value" entry virtual void write(Ostream&) const; }; diff --git a/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.H b/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.H index 1e56baf866..2dd84e81da 100644 --- a/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.H @@ -183,7 +183,7 @@ public: // IO - //- Write + //- Write includes "value" entry virtual void write(Ostream&) const; }; diff --git a/src/finiteArea/fields/faPatchFields/derived/uniformFixedGradient/uniformFixedGradientFaPatchField.H b/src/finiteArea/fields/faPatchFields/derived/uniformFixedGradient/uniformFixedGradientFaPatchField.H index 4c049d4f45..2490f1f622 100644 --- a/src/finiteArea/fields/faPatchFields/derived/uniformFixedGradient/uniformFixedGradientFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/derived/uniformFixedGradient/uniformFixedGradientFaPatchField.H @@ -161,12 +161,12 @@ public: } - // Member functions + // Member Functions //- Update the coefficients associated with the patch field virtual void updateCoeffs(); - //- Write + //- Write includes "value" entry virtual void write(Ostream& os) const; }; diff --git a/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.H b/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.H index 3bb1027458..cc21bfa0b3 100644 --- a/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.H @@ -167,7 +167,7 @@ public: //- Update the coefficients associated with the patch field virtual void updateCoeffs(); - //- Write + //- Write includes "value" entry virtual void write(Ostream& os) const; }; diff --git a/src/finiteArea/fields/faPatchFields/derived/uniformMixed/uniformMixedFaPatchField.H b/src/finiteArea/fields/faPatchFields/derived/uniformMixed/uniformMixedFaPatchField.H index ab3182b3a4..08d3a4a6b2 100644 --- a/src/finiteArea/fields/faPatchFields/derived/uniformMixed/uniformMixedFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/derived/uniformMixed/uniformMixedFaPatchField.H @@ -188,7 +188,7 @@ public: //- Update the coefficients associated with the patch field virtual void updateCoeffs(); - //- Write + //- Write includes "value" entry (for visualisation / restart) virtual void write(Ostream& os) const; }; diff --git a/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.C b/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.C index 3032a855ed..d77ef591d5 100644 --- a/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.C +++ b/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.C @@ -37,7 +37,7 @@ Foam::emptyFaePatchField::emptyFaePatchField const DimensionedField& iF ) : - faePatchField(p, iF, Field()) + faePatchField(p, iF, Field()) // zero-sized patch field {} @@ -50,7 +50,7 @@ Foam::emptyFaePatchField::emptyFaePatchField const faPatchFieldMapper& ) : - faePatchField(p, iF, Field()) + faePatchField(p, iF, Field()) // zero-sized patch field { if (!isType(this->patch())) { @@ -72,8 +72,11 @@ Foam::emptyFaePatchField::emptyFaePatchField const dictionary& dict ) : - faePatchField(p, iF, Field()) + faePatchField(p, iF, Field()) // zero-sized patch field { + // Empty means empty, so no patchType override + // with faePatchFieldBase::readDict(dict); + if (!isType(p)) { FatalIOErrorInFunction(dict) @@ -87,21 +90,21 @@ Foam::emptyFaePatchField::emptyFaePatchField template Foam::emptyFaePatchField::emptyFaePatchField ( - const emptyFaePatchField& ptf + const emptyFaePatchField& ptf, + const DimensionedField& iF ) : - faePatchField(ptf.patch(), ptf.internalField(), Field()) + faePatchField(ptf.patch(), iF, Field()) // zero-sized {} template Foam::emptyFaePatchField::emptyFaePatchField ( - const emptyFaePatchField& ptf, - const DimensionedField& iF + const emptyFaePatchField& ptf ) : - faePatchField(ptf.patch(), iF, Field()) + emptyFaePatchField(ptf, ptf.internalField()) {} diff --git a/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.H b/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.H index 6c7004db9f..3d9afcace4 100644 --- a/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.H +++ b/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.H @@ -73,7 +73,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is NO_READ. emptyFaePatchField ( const faPatch&, diff --git a/src/finiteVolume/fields/fvPatchFields/basic/basicSymmetry/basicSymmetryFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/basic/basicSymmetry/basicSymmetryFvPatchField.H index 33e2c8784e..9c9fabaf73 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/basicSymmetry/basicSymmetryFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/basic/basicSymmetry/basicSymmetryFvPatchField.H @@ -30,7 +30,8 @@ Group grpConstraintBoundaryConditions Description - A symmetry patch + A symmetry patch. + The "value" entry is NO_READ, NO_WRITE. SourceFiles basicSymmetryFvPatchField.C @@ -57,7 +58,6 @@ class basicSymmetryFvPatchField : public transformFvPatchField { - public: // Constructors @@ -69,7 +69,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is NO_READ. basicSymmetryFvPatchField ( const fvPatch&, @@ -77,8 +78,8 @@ public: const dictionary& ); - //- Construct by mapping given basicSymmetryFvPatchField onto a new - // patch + //- Construct by mapping given basicSymmetry patch field + //- onto a new patch basicSymmetryFvPatchField ( const basicSymmetryFvPatchField&, diff --git a/src/finiteVolume/fields/fvPatchFields/basic/calculated/calculatedFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/basic/calculated/calculatedFvPatchField.H index ab2abde60d..1b44100ead 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/calculated/calculatedFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/basic/calculated/calculatedFvPatchField.H @@ -31,11 +31,16 @@ Group grpGenericBoundaryConditions Description - This boundary condition is not designed to be evaluated; it is assmued + This boundary condition is not designed to be evaluated; it is assumed that the value is assigned via field assignment, and not via a call to e.g. \c updateCoeffs or \c evaluate. Usage + \table + Property | Description | Required | Default + value | field value | yes | + \endtable + Example of the boundary condition specification: \verbatim @@ -99,13 +104,13 @@ public: const fvPatch& p, const DimensionedField& iF, const dictionary& dict, - const bool valueReqd + const bool needValue ) : calculatedFvPatchField ( p, iF, dict, - (valueReqd? IOobjectOption::MUST_READ : IOobjectOption::NO_READ) + (needValue? IOobjectOption::MUST_READ : IOobjectOption::NO_READ) ) {} @@ -178,7 +183,7 @@ public: tmp> gradientBoundaryCoeffs() const; - //- Write + //- Write includes "value" entry virtual void write(Ostream&) const; }; diff --git a/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.H index 155a20cb7e..23ff2481f5 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.H @@ -33,6 +33,8 @@ Group Description Abstract base class for coupled patches. + The "value" entry is usually MUST_READ and always WRITE. + SourceFiles coupledFvPatchField.C @@ -98,13 +100,13 @@ public: const fvPatch& p, const DimensionedField& iF, const dictionary& dict, - const bool valueReqd + const bool needValue ) : coupledFvPatchField ( p, iF, dict, - (valueReqd? IOobjectOption::MUST_READ : IOobjectOption::NO_READ) + (needValue? IOobjectOption::MUST_READ : IOobjectOption::NO_READ) ) {} @@ -144,8 +146,7 @@ public: // Access - //- Return true if this patch field is derived from - // coupledFvPatchField. + //- True if this patch field is derived from coupledFvPatchField. virtual bool coupled() const { return true; @@ -268,7 +269,7 @@ public: ) const = 0; - //- Write + //- Write includes "value" entry virtual void write(Ostream&) const; }; diff --git a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C index 8a567b7150..7ce790c829 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C @@ -92,21 +92,21 @@ Foam::fixedValueFvPatchField::fixedValueFvPatchField template Foam::fixedValueFvPatchField::fixedValueFvPatchField ( - const fixedValueFvPatchField& ptf + const fixedValueFvPatchField& ptf, + const DimensionedField& iF ) : - fvPatchField(ptf) + fvPatchField(ptf, iF) {} template Foam::fixedValueFvPatchField::fixedValueFvPatchField ( - const fixedValueFvPatchField& ptf, - const DimensionedField& iF + const fixedValueFvPatchField& ptf ) : - fvPatchField(ptf, iF) + fixedValueFvPatchField(ptf, ptf.internalField()) {} diff --git a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H index 1abd1eb2b3..7c2fa1bcc8 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H @@ -111,13 +111,13 @@ public: const fvPatch& p, const DimensionedField& iF, const dictionary& dict, - const bool valueReqd + const bool needValue ) : fixedValueFvPatchField ( p, iF, dict, - (valueReqd? IOobjectOption::MUST_READ : IOobjectOption::NO_READ) + (needValue? IOobjectOption::MUST_READ : IOobjectOption::NO_READ) ) {} @@ -168,6 +168,9 @@ public: //- False: this patch field is not altered by assignment. virtual bool assignable() const { return false; } + //- Write includes "value" entry + virtual void write(Ostream&) const; + // Evaluation functions @@ -194,11 +197,7 @@ public: virtual tmp> gradientBoundaryCoeffs() const; - //- Write - virtual void write(Ostream&) const; - - - // Member operators + // Member Operators virtual void operator=(const UList&) {} diff --git a/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchField.H index 0576d3ccce..9211155c71 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchField.H @@ -30,15 +30,16 @@ Group grpGenericBoundaryConditions Description - Foam::transformFvPatchField + Intermediate layer (not used directly as a user boundary condition). + The "value" entry is NO_READ, NO_WRITE. SourceFiles transformFvPatchField.C \*---------------------------------------------------------------------------*/ -#ifndef transformFvPatchField_H -#define transformFvPatchField_H +#ifndef Foam_transformFvPatchField_H +#define Foam_transformFvPatchField_H #include "fvPatchField.H" @@ -56,7 +57,6 @@ class transformFvPatchField : public fvPatchField { - public: //- Runtime type information @@ -72,7 +72,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is NO_READ. transformFvPatchField ( const fvPatch&, diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C index 487bdb8dff..7a70acb1e0 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C @@ -51,7 +51,7 @@ Foam::cyclicFvPatchField::cyclicFvPatchField const fvPatch& p, const DimensionedField& iF, const dictionary& dict, - const bool valueRequired + const bool needValue ) : coupledFvPatchField(p, iF, dict, IOobjectOption::NO_READ), @@ -68,7 +68,7 @@ Foam::cyclicFvPatchField::cyclicFvPatchField << exit(FatalIOError); } - if (valueRequired) + if (needValue) { this->evaluate(Pstream::commsTypes::blocking); } @@ -324,4 +324,5 @@ void Foam::cyclicFvPatchField::manipulateMatrix } } + // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H index 7b265ce604..b8199cb28e 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H @@ -34,6 +34,8 @@ Description This boundary condition enforces a cyclic condition between a pair of boundaries. + The "value" entry is NO_READ. + Usage Example of the boundary condition specification: \verbatim @@ -75,7 +77,7 @@ class cyclicFvPatchField virtual public cyclicLduInterfaceField, public coupledFvPatchField { - // Private data + // Private Data //- Local reference cast into the cyclic patch const cyclicFvPatch& cyclicPatch_; @@ -113,7 +115,7 @@ public: const fvPatch&, const DimensionedField&, const dictionary&, - const bool valueRequired = true + const bool needValue = true //!< evaluate ); //- Construct by mapping given cyclicFvPatchField onto a new patch @@ -154,7 +156,7 @@ public: } - // Member functions + // Member Functions // Access diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicSlip/cyclicSlipFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicSlip/cyclicSlipFvPatchField.C index 215d3655b8..051ef0b8f8 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicSlip/cyclicSlipFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicSlip/cyclicSlipFvPatchField.C @@ -61,7 +61,7 @@ Foam::cyclicSlipFvPatchField::cyclicSlipFvPatchField const dictionary& dict ) : - cyclicFvPatchField(p, iF, dict) + cyclicFvPatchField(p, iF, dict) // needValue (evaluate) = true {} diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicSlip/cyclicSlipFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicSlip/cyclicSlipFvPatchField.H index da0eb6fef0..3283b60e5e 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicSlip/cyclicSlipFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicSlip/cyclicSlipFvPatchField.H @@ -33,6 +33,8 @@ Description This boundary condition is a light wrapper around the cyclicFvPatchField condition, providing no new functionality. + The "value" entry is NO_READ. + Usage Example of the boundary condition specification: \verbatim @@ -50,8 +52,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef cyclicSlipFvPatchField_H -#define cyclicSlipFvPatchField_H +#ifndef Foam_cyclicSlipFvPatchField_H +#define Foam_cyclicSlipFvPatchField_H #include "cyclicFvPatchField.H" #include "cyclicSlipFvPatch.H" @@ -70,7 +72,6 @@ class cyclicSlipFvPatchField : public cyclicFvPatchField { - public: //- Runtime type information @@ -86,7 +87,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is NO_READ. cyclicSlipFvPatchField ( const fvPatch&, diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.C index 846c33a216..5bbc2ddd6f 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,7 +38,7 @@ Foam::emptyFvPatchField::emptyFvPatchField const DimensionedField& iF ) : - fvPatchField(p, iF, Field(0)) + fvPatchField(p, iF, Field()) // zero-sized patch field {} @@ -50,7 +51,7 @@ Foam::emptyFvPatchField::emptyFvPatchField const fvPatchFieldMapper& ) : - fvPatchField(p, iF, Field(0)) + fvPatchField(p, iF, Field()) // zero-sized patch field { if (!isType(p)) { @@ -73,8 +74,11 @@ Foam::emptyFvPatchField::emptyFvPatchField const dictionary& dict ) : - fvPatchField(p, iF, Field(0)) + fvPatchField(p, iF, Field()) // zero-sized patch field { + // Empty means empty, so no patchType override + // with fvPatchFieldBase::readDict(dict); + if (!isType(p)) { FatalIOErrorInFunction(dict) @@ -91,26 +95,21 @@ Foam::emptyFvPatchField::emptyFvPatchField template Foam::emptyFvPatchField::emptyFvPatchField ( - const emptyFvPatchField& ptf + const emptyFvPatchField& ptf, + const DimensionedField& iF ) : - fvPatchField - ( - ptf.patch(), - ptf.internalField(), - Field(0) - ) + fvPatchField(ptf.patch(), iF, Field()) // zero-sized {} template Foam::emptyFvPatchField::emptyFvPatchField ( - const emptyFvPatchField& ptf, - const DimensionedField& iF + const emptyFvPatchField& ptf ) : - fvPatchField(ptf.patch(), iF, Field(0)) + emptyFvPatchField(ptf, ptf.internalField()) {} diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.H index d86c9084cb..b22e96584c 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.H @@ -33,7 +33,9 @@ Description This boundary condition provides an 'empty' condition for reduced dimensions cases, i.e. 1- and 2-D geometries. Apply this condition to patches whose normal is aligned to geometric directions that do not - constitue solution directions. + constitute solution directions. + + The "value" entry is NO_READ, NO_WRITE. Usage Example of the boundary condition specification: @@ -84,7 +86,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is NO_READ. emptyFvPatchField ( const fvPatch&, diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C index 2b5e3a364b..fb9a97b348 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -60,14 +60,11 @@ Foam::jumpCyclicFvPatchField::jumpCyclicFvPatchField const fvPatch& p, const DimensionedField& iF, const dictionary& dict, - const bool valueRequired + const bool needValue ) : - cyclicFvPatchField(p, iF, dict, valueRequired) -{ - // Call this evaluation in derived classes - //this->evaluate(Pstream::commsTypes::blocking); -} + cyclicFvPatchField(p, iF, dict, needValue) +{} template diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H index 28c803b659..199215c628 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H @@ -34,6 +34,8 @@ Description This boundary condition provides a base class for coupled-cyclic conditions with a specified 'jump' (or offset) between the values + The "value" entry is NO_READ. + See also Foam::cyclicFvPatchField @@ -42,8 +44,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef jumpCyclicFvPatchField_H -#define jumpCyclicFvPatchField_H +#ifndef Foam_jumpCyclicFvPatchField_H +#define Foam_jumpCyclicFvPatchField_H #include "cyclicFvPatchField.H" @@ -61,7 +63,6 @@ class jumpCyclicFvPatchField : public cyclicFvPatchField { - public: //- Runtime type information @@ -77,13 +78,14 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is NO_READ. jumpCyclicFvPatchField ( const fvPatch&, const DimensionedField&, const dictionary&, - const bool valueRequired = true + const bool needValue = true //!< evaluate ); //- Construct by mapping given jumpCyclicFvPatchField onto a new patch diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicFvPatchField.C index f4ac86faf3..04cb2a9220 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicFvPatchField.C @@ -50,7 +50,7 @@ nonuniformTransformCyclicFvPatchField const dictionary& dict ) : - cyclicFvPatchField(p, iF, dict) + cyclicFvPatchField(p, iF, dict) // needValue (evaluate) = true {} diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicFvPatchField.H index 9f325feb1b..fa4b6f6701 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicFvPatchField.H @@ -33,6 +33,8 @@ Description This boundary condition enforces a cyclic condition between a pair of boundaries, incorporating a non-uniform transformation. + The "value" entry is NO_READ. + SourceFiles nonuniformTransformCyclicFvPatchField.C nonuniformTransformCyclicFvPatchFields.H @@ -41,8 +43,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef nonuniformTransformCyclicFvPatchField_H -#define nonuniformTransformCyclicFvPatchField_H +#ifndef Foam_nonuniformTransformCyclicFvPatchField_H +#define Foam_nonuniformTransformCyclicFvPatchField_H #include "cyclicFvPatchField.H" #include "nonuniformTransformCyclicFvPatch.H" @@ -61,8 +63,6 @@ class nonuniformTransformCyclicFvPatchField : public cyclicFvPatchField { - // Private data - public: //- Runtime type information @@ -78,7 +78,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is NO_READ. nonuniformTransformCyclicFvPatchField ( const fvPatch&, diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C index a4c1e57ea7..793b638cc6 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C @@ -28,7 +28,6 @@ License #include "processorFvPatchField.H" #include "processorFvPatch.H" -#include "demandDrivenData.H" #include "transformField.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.C index c03c65b744..5c3f68ec4b 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.C @@ -135,11 +135,4 @@ Foam::processorCyclicFvPatchField::processorCyclicFvPatchField {} -// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // - -template -Foam::processorCyclicFvPatchField::~processorCyclicFvPatchField() -{} - - // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.H index 08e018d2cb..8287cd4359 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.H @@ -73,7 +73,7 @@ class processorCyclicFvPatchField : public processorFvPatchField { - // Private data + // Private Data //- Local reference cast into the processor patch const processorCyclicFvPatch& procPatch_; @@ -146,10 +146,10 @@ public: //- Destructor - virtual ~processorCyclicFvPatchField(); + virtual ~processorCyclicFvPatchField() = default; - // Member functions + // Member Functions // Access diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/symmetry/symmetryFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/symmetry/symmetryFvPatchField.H index 0727afe5f8..6f2ec33e0d 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/symmetry/symmetryFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/symmetry/symmetryFvPatchField.H @@ -69,7 +69,6 @@ class symmetryFvPatchField : public basicSymmetryFvPatchField { - public: //- Runtime type information diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C index e3fd64d58d..8c2b3eb61c 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,7 +32,6 @@ License #include "symmTransform.H" #include "diagTensor.H" - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template @@ -41,7 +41,7 @@ Foam::wedgeFvPatchField::wedgeFvPatchField const DimensionedField& iF ) : - transformFvPatchField(p, iF) + parent_bctype(p, iF) {} @@ -54,7 +54,7 @@ Foam::wedgeFvPatchField::wedgeFvPatchField const fvPatchFieldMapper& mapper ) : - transformFvPatchField(ptf, p, iF, mapper) + parent_bctype(ptf, p, iF, mapper) { if (!isType(this->patch())) { @@ -77,7 +77,7 @@ Foam::wedgeFvPatchField::wedgeFvPatchField const dictionary& dict ) : - transformFvPatchField(p, iF, dict) + parent_bctype(p, iF, dict) // "value" is NO_READ { if (!isType(p)) { @@ -97,21 +97,21 @@ Foam::wedgeFvPatchField::wedgeFvPatchField template Foam::wedgeFvPatchField::wedgeFvPatchField ( - const wedgeFvPatchField& ptf + const wedgeFvPatchField& ptf, + const DimensionedField& iF ) : - transformFvPatchField(ptf) + parent_bctype(ptf, iF) {} template Foam::wedgeFvPatchField::wedgeFvPatchField ( - const wedgeFvPatchField& ptf, - const DimensionedField& iF + const wedgeFvPatchField& ptf ) : - transformFvPatchField(ptf, iF) + wedgeFvPatchField(ptf, ptf.internalField()) {} diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.H index 36c2252e7e..6d8e34e98b 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.H @@ -33,6 +33,8 @@ Description This boundary condition is similar to the cyclic condition, except that it is applied to 2-D geometries. + The "value" entry is NO_READ, NO_WRITE. + Usage Example of the boundary condition specification: \verbatim @@ -50,8 +52,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef wedgeFvPatchField_H -#define wedgeFvPatchField_H +#ifndef Foam_wedgeFvPatchField_H +#define Foam_wedgeFvPatchField_H #include "transformFvPatchField.H" #include "wedgeFvPatch.H" @@ -70,6 +72,9 @@ class wedgeFvPatchField : public transformFvPatchField { + //- The parent boundary condition type + typedef transformFvPatchField parent_bctype; + public: @@ -86,7 +91,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is NO_READ. wedgeFvPatchField ( const fvPatch&, diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C index 39b7394feb..921199406e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C @@ -67,7 +67,7 @@ Foam::fanFvPatchField::fanFvPatchField const dictionary& dict ) : - uniformJumpFvPatchField(p, iF, dict, false), // Pass no valueRequired + uniformJumpFvPatchField(p, iF, dict, false), // needValue = false phiName_(dict.getOrDefault("phi", "phi")), rhoName_(dict.getOrDefault("rho", "rho")), uniformJump_(dict.getOrDefault("uniformJump", false)), diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C index e55831b999..8d62f14c27 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C @@ -70,10 +70,10 @@ Foam::fixedJumpFvPatchField::fixedJumpFvPatchField const fvPatch& p, const DimensionedField& iF, const dictionary& dict, - const bool valueRequired + const bool needValue ) : - jumpCyclicFvPatchField(p, iF, dict, false), // Pass no valueRequired + jumpCyclicFvPatchField(p, iF, dict, false), // needValue = false jump_(p.size(), Zero), jump0_(p.size(), Zero), minJump_(dict.getOrDefault("minJump", pTraits::min)), @@ -82,7 +82,7 @@ Foam::fixedJumpFvPatchField::fixedJumpFvPatchField { if (this->cyclicPatch().owner()) { - if (valueRequired) + if (needValue) { jump_.assign("jump", dict, p.size(), IOobjectOption::MUST_READ); } @@ -90,7 +90,7 @@ Foam::fixedJumpFvPatchField::fixedJumpFvPatchField jump0_.assign("jump0", dict, p.size(), IOobjectOption::LAZY_READ); } - if (valueRequired) + if (needValue) { if (!this->readValueEntry(dict)) { diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.H index f9e340bbcc..441b420dea 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.H @@ -128,7 +128,7 @@ public: const fvPatch&, const DimensionedField&, const dictionary&, - const bool valueRequired = true + const bool needValue = true ); //- Construct by mapping given fixedJumpFvPatchField onto a diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalSlip/fixedNormalSlipFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalSlip/fixedNormalSlipFvPatchField.C index 557ffce494..32c993eaa1 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalSlip/fixedNormalSlipFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalSlip/fixedNormalSlipFvPatchField.C @@ -39,7 +39,7 @@ Foam::fixedNormalSlipFvPatchField::fixedNormalSlipFvPatchField ) : parent_bctype(p, iF), - fixedValue_(p.size(), Zero), + fixedValue_(p.size(), Foam::zero{}), writeValue_(false) {} @@ -72,6 +72,7 @@ Foam::fixedNormalSlipFvPatchField::fixedNormalSlipFvPatchField writeValue_(dict.getOrDefault("writeValue", false)) { fvPatchFieldBase::readDict(dict); + evaluate(); } @@ -181,11 +182,13 @@ template void Foam::fixedNormalSlipFvPatchField::write(Ostream& os) const { this->parent_bctype::write(os); - fixedValue_.writeEntry("fixedValue", os); - if (writeValue_) { os.writeEntry("writeValue", "true"); + } + fixedValue_.writeEntry("fixedValue", os); + if (writeValue_) + { fvPatchField::writeValueEntry(os); } } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalSlip/fixedNormalSlipFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalSlip/fixedNormalSlipFvPatchField.H index 7fe1f59490..8fdfb7e7fd 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalSlip/fixedNormalSlipFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalSlip/fixedNormalSlipFvPatchField.H @@ -36,6 +36,8 @@ Description The tangential component is treated as slip, i.e. copied from the internal field. + The "value" entry is NO_READ, optional write. + Usage Example of the boundary condition specification: \verbatim @@ -76,8 +78,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef fixedNormalSlipFvPatchField_H -#define fixedNormalSlipFvPatchField_H +#ifndef Foam_fixedNormalSlipFvPatchField_H +#define Foam_fixedNormalSlipFvPatchField_H #include "transformFvPatchField.H" @@ -123,7 +125,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is NO_READ. fixedNormalSlipFvPatchField ( const fvPatch&, diff --git a/src/finiteVolume/fields/fvPatchFields/derived/partialSlip/partialSlipFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/partialSlip/partialSlipFvPatchField.C index cfb77c5732..b11935b557 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/partialSlip/partialSlipFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/partialSlip/partialSlipFvPatchField.C @@ -39,7 +39,7 @@ Foam::partialSlipFvPatchField::partialSlipFvPatchField ) : parent_bctype(p, iF), - refValue_(p.size(), Zero), + refValue_(p.size(), Foam::zero{}), valueFraction_(p.size(), 1.0), writeValue_(false) {} @@ -70,7 +70,7 @@ Foam::partialSlipFvPatchField::partialSlipFvPatchField ) : parent_bctype(p, iF), - refValue_(p.size(), Zero), + refValue_(p.size(), Foam::zero{}), valueFraction_("valueFraction", dict, p.size()), writeValue_(dict.getOrDefault("writeValue", false)) { @@ -86,10 +86,11 @@ Foam::partialSlipFvPatchField::partialSlipFvPatchField template Foam::partialSlipFvPatchField::partialSlipFvPatchField ( - const partialSlipFvPatchField& ptf + const partialSlipFvPatchField& ptf, + const DimensionedField& iF ) : - parent_bctype(ptf), + parent_bctype(ptf, iF), refValue_(ptf.refValue_), valueFraction_(ptf.valueFraction_), writeValue_(ptf.writeValue_) @@ -99,14 +100,10 @@ Foam::partialSlipFvPatchField::partialSlipFvPatchField template Foam::partialSlipFvPatchField::partialSlipFvPatchField ( - const partialSlipFvPatchField& ptf, - const DimensionedField& iF + const partialSlipFvPatchField& ptf ) : - parent_bctype(ptf, iF), - refValue_(ptf.refValue_), - valueFraction_(ptf.valueFraction_), - writeValue_(ptf.writeValue_) + partialSlipFvPatchField(ptf, ptf.internalField()) {} @@ -204,12 +201,14 @@ template void Foam::partialSlipFvPatchField::write(Ostream& os) const { this->parent_bctype::write(os); - refValue_.writeEntry("refValue", os); - valueFraction_.writeEntry("valueFraction", os); - if (writeValue_) { os.writeEntry("writeValue", "true"); + } + refValue_.writeEntry("refValue", os); + valueFraction_.writeEntry("valueFraction", os); + if (writeValue_) + { fvPatchField::writeValueEntry(os); } } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/partialSlip/partialSlipFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/partialSlip/partialSlipFvPatchField.H index eb5ed46922..a81ce92912 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/partialSlip/partialSlipFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/partialSlip/partialSlipFvPatchField.H @@ -31,8 +31,10 @@ Group grpWallBoundaryConditions grpGenericBoundaryConditions Description - This boundary condition provides a partial slip condition. The amount of - slip is controlled by a user-supplied field. + This boundary condition provides a partial slip condition. + The amount of slip is controlled by a user-supplied field. + + The "value" entry is NO_READ, optional write. Usage \table @@ -50,7 +52,6 @@ Usage type partialSlip; refValue uniform 0.001; valueFraction uniform 0.1; - value uniform 0; } \endverbatim @@ -62,8 +63,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef partialSlipFvPatchField_H -#define partialSlipFvPatchField_H +#ifndef Foam_partialSlipFvPatchField_H +#define Foam_partialSlipFvPatchField_H #include "transformFvPatchField.H" @@ -112,7 +113,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is NO_READ. partialSlipFvPatchField ( const fvPatch&, @@ -120,7 +122,8 @@ public: const dictionary& ); - //- Construct by mapping given partialSlipFvPatchField onto a new patch + //- Construct by mapping given partialSlip patch field + //- onto a new patch partialSlipFvPatchField ( const partialSlipFvPatchField&, @@ -163,6 +166,7 @@ public: //- False: this patch field is not altered by assignment virtual bool assignable() const { return false; } + // Access virtual Field& refValue() diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C index 1f117d268c..deca4b4732 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C @@ -62,13 +62,13 @@ Foam::uniformJumpFvPatchField::uniformJumpFvPatchField const fvPatch& p, const DimensionedField& iF, const dictionary& dict, - const bool valueRequired + const bool needValue ) : - fixedJumpFvPatchField(p, iF, dict, false), // Pass no valueRequired + fixedJumpFvPatchField(p, iF, dict, false), // needValue = false jumpTable_() { - if (valueRequired) + if (needValue) { if (this->cyclicPatch().owner()) { diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.H index 09be775aed..a953274fc9 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.H @@ -118,7 +118,7 @@ public: const fvPatch&, const DimensionedField&, const dictionary&, - const bool valueRequired = true + const bool needValue = true ); //- Construct by mapping given uniformJumpFvPatchField onto a diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H index 9056467691..993433fd61 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H @@ -430,13 +430,13 @@ public: const fvPatch& p, const DimensionedField& iF, const dictionary& dict, - const bool valueReqd + const bool needValue ) : fvPatchField ( p, iF, dict, - (valueReqd? IOobjectOption::MUST_READ : IOobjectOption::NO_READ) + (needValue? IOobjectOption::MUST_READ : IOobjectOption::NO_READ) ) {} diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/calculated/calculatedFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/basic/calculated/calculatedFvsPatchField.C index ed1536312c..0cfa7e3ef0 100644 --- a/src/finiteVolume/fields/fvsPatchFields/basic/calculated/calculatedFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/basic/calculated/calculatedFvsPatchField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2021-2023 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -131,4 +131,14 @@ Foam::fvsPatchField::NewCalculatedType } +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::calculatedFvsPatchField::write(Ostream& os) const +{ + fvsPatchField::write(os); + fvsPatchField::writeValueEntry(os); +} + + // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/calculated/calculatedFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/basic/calculated/calculatedFvsPatchField.H index bd8b64db01..1e8914fd25 100644 --- a/src/finiteVolume/fields/fvsPatchFields/basic/calculated/calculatedFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/basic/calculated/calculatedFvsPatchField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,7 +28,25 @@ Class Foam::calculatedFvsPatchField Description - Foam::calculatedFvsPatchField + This boundary condition is not designed to be evaluated; it is assumed + that the value is assigned via field assignment. + + The "value" entry is MUST_READ. + +Usage + \table + Property | Description | Required | Default + value | Patch face values | yes | + \endtable + + Example of the boundary condition specification: + \verbatim + + { + type calculated; + value uniform (0 0 0); // Required value entry + } + \endverbatim SourceFiles calculatedFvsPatchField.C @@ -118,6 +137,9 @@ public: //- True: this patch field fixes a value. virtual bool fixesValue() const { return true; } + + //- Write includes "value" entry + virtual void write(Ostream&) const; }; diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/coupled/coupledFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/basic/coupled/coupledFvsPatchField.C index 5c3d033a66..939aac9d7c 100644 --- a/src/finiteVolume/fields/fvsPatchFields/basic/coupled/coupledFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/basic/coupled/coupledFvsPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -57,10 +58,11 @@ Foam::coupledFvsPatchField::coupledFvsPatchField ( const fvPatch& p, const DimensionedField& iF, - const dictionary& dict + const dictionary& dict, + IOobjectOption::readOption requireValue ) : - fvsPatchField(p, iF, dict) + fvsPatchField(p, iF, dict, requireValue) {} @@ -98,4 +100,14 @@ Foam::coupledFvsPatchField::coupledFvsPatchField {} +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::coupledFvsPatchField::write(Ostream& os) const +{ + fvsPatchField::write(os); + fvsPatchField::writeValueEntry(os); +} + + // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/coupled/coupledFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/basic/coupled/coupledFvsPatchField.H index 221630943f..b6ce0ea9f0 100644 --- a/src/finiteVolume/fields/fvsPatchFields/basic/coupled/coupledFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/basic/coupled/coupledFvsPatchField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,15 +28,17 @@ Class Foam::coupledFvsPatchField Description - Foam::coupledFvsPatchField + Abstract base class for coupled patches. + + The "value" entry is usually MUST_READ and always WRITE. SourceFiles coupledFvsPatchField.C \*---------------------------------------------------------------------------*/ -#ifndef coupledFvsPatchField_H -#define coupledFvsPatchField_H +#ifndef Foam_coupledFvsPatchField_H +#define Foam_coupledFvsPatchField_H #include "fvsPatchField.H" #include "coupledFvPatch.H" @@ -46,7 +49,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class coupledFvsPatch Declaration + Class coupledFvsPatchField Declaration \*---------------------------------------------------------------------------*/ template @@ -54,7 +57,6 @@ class coupledFvsPatchField : public fvsPatchField { - public: //- Runtime type information @@ -83,7 +85,8 @@ public: ( const fvPatch&, const DimensionedField&, - const dictionary& + const dictionary&, + IOobjectOption::readOption requireValue = IOobjectOption::MUST_READ ); //- Construct by mapping the given coupledFvsPatchField onto a new patch @@ -118,16 +121,16 @@ public: ) const = 0; - // Member functions + // Member Functions - // Access + //- True if this patch field is derived from coupledFvsPatchField + virtual bool coupled() const + { + return true; + } - //- Return true if this patch field is derived from - // coupledFvsPatchField. - virtual bool coupled() const - { - return true; - } + //- Write includes "value" entry + virtual void write(Ostream&) const; }; diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C index f457b1d07d..2d061f7ced 100644 --- a/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -57,7 +58,8 @@ Foam::fixedValueFvsPatchField::fixedValueFvsPatchField ( const fvPatch& p, const DimensionedField& iF, - const dictionary& dict + const dictionary& dict, + IOobjectOption::readOption requireValue ) : fvsPatchField(p, iF, dict, IOobjectOption::MUST_READ) @@ -80,21 +82,21 @@ Foam::fixedValueFvsPatchField::fixedValueFvsPatchField template Foam::fixedValueFvsPatchField::fixedValueFvsPatchField ( - const fixedValueFvsPatchField& ptf + const fixedValueFvsPatchField& ptf, + const DimensionedField& iF ) : - fvsPatchField(ptf) + fvsPatchField(ptf, iF) {} template Foam::fixedValueFvsPatchField::fixedValueFvsPatchField ( - const fixedValueFvsPatchField& ptf, - const DimensionedField& iF + const fixedValueFvsPatchField& ptf ) : - fvsPatchField(ptf, iF) + fixedValueFvsPatchField(ptf, ptf.internalField()) {} @@ -138,4 +140,12 @@ Foam::fixedValueFvsPatchField::gradientBoundaryCoeffs() const } +template +void Foam::fixedValueFvsPatchField::write(Ostream& os) const +{ + fvsPatchField::write(os); + fvsPatchField::writeValueEntry(os); +} + + // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.H index ab5ec9dc42..5934499fe0 100644 --- a/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,15 +28,33 @@ Class Foam::fixedValueFvsPatchField Description - Foam::fixedValueFvsPatchField + This boundary condition supplies a fixed value constraint, and is the base + class for a number of other boundary conditions. + + The "value" entry is MUST_READ. + +Usage + \table + Property | Description | Required | Default + value | Patch face values | yes | + \endtable + + Example of the boundary condition specification: + \verbatim + + { + type fixedValue; + value uniform 0; // Example for scalar field usage + } + \endverbatim SourceFiles fixedValueFvsPatchField.C \*---------------------------------------------------------------------------*/ -#ifndef fixedValueFvsPatchField_H -#define fixedValueFvsPatchField_H +#ifndef Foam_fixedValueFvsPatchField_H +#define Foam_fixedValueFvsPatchField_H #include "fvsPatchField.H" @@ -45,7 +64,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class fixedValueFvsPatch Declaration + Class fixedValueFvsPatchField Declaration \*---------------------------------------------------------------------------*/ template @@ -81,7 +100,8 @@ public: ( const fvPatch&, const DimensionedField&, - const dictionary& + const dictionary&, + IOobjectOption::readOption requireValue = IOobjectOption::MUST_READ ); //- Construct by mapping the given fixedValue patch field @@ -127,6 +147,9 @@ public: //- True: this patch field fixes a value. virtual bool fixesValue() const { return true; } + //- Write includes "value" entry + virtual void write(Ostream&) const; + // Evaluation functions @@ -153,7 +176,7 @@ public: virtual tmp> gradientBoundaryCoeffs() const; - // Member operators + // Member Operators virtual void operator=(const UList&) {} diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/sliced/slicedFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/basic/sliced/slicedFvsPatchField.C index 717918883f..de49ba50a5 100644 --- a/src/finiteVolume/fields/fvsPatchFields/basic/sliced/slicedFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/basic/sliced/slicedFvsPatchField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2023 OpenCFD Ltd. + Copyright (C) 2023-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -131,4 +131,14 @@ Foam::slicedFvsPatchField::~slicedFvsPatchField() } +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::slicedFvsPatchField::write(Ostream& os) const +{ + fvsPatchField::write(os); + fvsPatchField::writeValueEntry(os); +} + + // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/sliced/slicedFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/basic/sliced/slicedFvsPatchField.H index 42c92679d9..3a82030519 100644 --- a/src/finiteVolume/fields/fvsPatchFields/basic/sliced/slicedFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/basic/sliced/slicedFvsPatchField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2023 OpenCFD Ltd. + Copyright (C) 2023-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -89,7 +89,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + // Not implemented. slicedFvsPatchField ( const fvPatch&, @@ -98,6 +99,7 @@ public: ); //- Construct by mapping the given sliced patch field onto a new patch + // Not implemented. slicedFvsPatchField ( const slicedFvsPatchField&, @@ -141,6 +143,9 @@ public: //- True: this patch field fixes a value. virtual bool fixesValue() const { return true; } + //- Write includes "value" entry + virtual void write(Ostream&) const; + // Member Operators diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclic/cyclicFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclic/cyclicFvsPatchField.H index c609d02df9..384638a754 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclic/cyclicFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclic/cyclicFvsPatchField.H @@ -27,15 +27,27 @@ Class Foam::cyclicFvsPatchField Description - Foam::cyclicFvsPatchField + This boundary condition enforces a cyclic condition between a pair of + boundaries. + + The "value" entry is NO_READ, but is written. + +Usage + Example of the boundary condition specification: + \verbatim + + { + type cyclic; + } + \endverbatim SourceFiles cyclicFvsPatchField.C \*---------------------------------------------------------------------------*/ -#ifndef cyclicFvsPatchField_H -#define cyclicFvsPatchField_H +#ifndef Foam_cyclicFvsPatchField_H +#define Foam_cyclicFvsPatchField_H #include "coupledFvsPatchField.H" #include "cyclicFvPatch.H" @@ -46,7 +58,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class cyclicFvsPatch Declaration + Class cyclicFvsPatchField Declaration \*---------------------------------------------------------------------------*/ template @@ -54,7 +66,7 @@ class cyclicFvsPatchField : public coupledFvsPatchField { - // Private data + // Private Data //- Local reference cast into the cyclic patch const cyclicFvPatch& cyclicPatch_; @@ -75,7 +87,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is NO_READ. cyclicFvsPatchField ( const fvPatch&, diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.C index 1a63a8b724..96fb0a15bc 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.C @@ -117,7 +117,7 @@ bool Foam::cyclicACMIFvsPatchField::coupled() const { if ( - Pstream::parRun() + UPstream::parRun() || ( this->cyclicACMIPatch_.size() && this->cyclicACMIPatch_.cyclicACMIPatch().neighbPatch().size() diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.H index da9480eb7f..b16faeb228 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.H @@ -27,7 +27,9 @@ Class Foam::cyclicACMIFvsPatchField Description - Foam::cyclicACMIFvsPatchField + This boundary condition enforces a cyclic condition between a pair of + boundaries, whereby communication between the patches is performed using + an arbitrarily coupled mesh interface (ACMI) interpolation. SourceFiles cyclicACMIFvsPatchField.C @@ -54,7 +56,7 @@ class cyclicACMIFvsPatchField : public coupledFvsPatchField { - // Private data + // Private Data //- Local reference cast into the cyclic patch const cyclicACMIFvPatch& cyclicACMIPatch_; @@ -75,7 +77,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is MUST_READ. cyclicACMIFvsPatchField ( const fvPatch&, diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.H index 2550303c73..59bdcab69f 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.H @@ -27,7 +27,11 @@ Class Foam::cyclicAMIFvsPatchField Description - Foam::cyclicAMIFvsPatchField + This boundary condition enforces a cyclic condition between a pair of + boundaries, whereby communication between the patches is performed using + an arbitrary mesh interface (AMI) interpolation. + + The "value" entry is MUST_READ. SourceFiles cyclicAMIFvsPatchField.C @@ -54,7 +58,7 @@ class cyclicAMIFvsPatchField : public coupledFvsPatchField { - // Private data + // Private Data //- Local reference cast into the cyclic patch const cyclicAMIFvPatch& cyclicAMIPatch_; @@ -75,7 +79,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is MUST_READ. cyclicAMIFvsPatchField ( const fvPatch&, diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.C index 489cb7de84..5c1d93d7d5 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,7 +39,7 @@ Foam::emptyFvsPatchField::emptyFvsPatchField const DimensionedField& iF ) : - fvsPatchField(p, iF, Field(0)) + fvsPatchField(p, iF, Field()) // zero-sized patch field {} @@ -50,8 +51,11 @@ Foam::emptyFvsPatchField::emptyFvsPatchField const dictionary& dict ) : - fvsPatchField(p, iF, Field(0)) + fvsPatchField(p, iF, Field()) // zero-sized patch field { + // Empty means empty, so no patchType override + // with fvsPatchFieldBase::readDict(dict); + if (!isType(p)) { FatalIOErrorInFunction(dict) @@ -71,7 +75,7 @@ Foam::emptyFvsPatchField::emptyFvsPatchField const fvPatchFieldMapper& ) : - fvsPatchField(p, iF, Field(0)) + fvsPatchField(p, iF, Field()) // zero-sized patch field { if (!isType(this->patch())) { @@ -88,26 +92,21 @@ Foam::emptyFvsPatchField::emptyFvsPatchField template Foam::emptyFvsPatchField::emptyFvsPatchField ( - const emptyFvsPatchField& ptf + const emptyFvsPatchField& ptf, + const DimensionedField& iF ) : - fvsPatchField - ( - ptf.patch(), - ptf.internalField(), - Field(0) - ) + fvsPatchField(ptf.patch(), iF, Field()) // zero-sized {} template Foam::emptyFvsPatchField::emptyFvsPatchField ( - const emptyFvsPatchField& ptf, - const DimensionedField& iF + const emptyFvsPatchField& ptf ) : - fvsPatchField(ptf.patch(), iF, Field(0)) + emptyFvsPatchField(ptf, ptf.internalField()) {} diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.H index 7641321852..6a70355075 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.H @@ -27,7 +27,19 @@ Class Foam::emptyFvsPatchField Description - Foam::emptyFvsPatchField + This boundary condition provides an 'empty' condition for reduced + dimensions cases. + + The "value" entry is NO_READ, NO_WRITE. + +Usage + Example of the boundary condition specification: + \verbatim + + { + type empty; + } + \endverbatim SourceFiles emptyFvsPatchField.C @@ -69,7 +81,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is NO_READ. emptyFvsPatchField ( const fvPatch&, @@ -115,9 +128,9 @@ public: } - // Member functions + // Member Functions - // Mapping functions + // Mapping Functions //- Map (and resize as needed) from self given a mapping object virtual void autoMap diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/processor/processorFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/processor/processorFvsPatchField.C index f5a44ebd4c..4d538caa6b 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/processor/processorFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/processor/processorFvsPatchField.C @@ -122,11 +122,4 @@ Foam::processorFvsPatchField::processorFvsPatchField {} -// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // - -template -Foam::processorFvsPatchField::~processorFvsPatchField() -{} - - // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/processor/processorFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/processor/processorFvsPatchField.H index dd96291ee6..8a4fb3a093 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/processor/processorFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/processor/processorFvsPatchField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,15 +28,26 @@ Class Foam::processorFvsPatchField Description - Foam::processorFvsPatchField + This boundary condition enables processor communication across patches. + + The "value" entry is MUST_READ. + + Example of the boundary condition specification: + \verbatim + + { + type processor; + value uniform (0 0 0); // Mandatory + } + \endverbatim SourceFiles processorFvsPatchField.C \*---------------------------------------------------------------------------*/ -#ifndef processorFvsPatchField_H -#define processorFvsPatchField_H +#ifndef Foam_processorFvsPatchField_H +#define Foam_processorFvsPatchField_H #include "coupledFvsPatchField.H" #include "processorFvPatch.H" @@ -54,7 +66,7 @@ class processorFvsPatchField : public coupledFvsPatchField { - // Private data + // Private Data //- Local reference cast into the processor patch const processorFvPatch& procPatch_; @@ -83,7 +95,8 @@ public: const Field& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is MUST_READ. processorFvsPatchField ( const fvPatch&, @@ -127,15 +140,15 @@ public: //- Destructor - virtual ~processorFvsPatchField(); + virtual ~processorFvsPatchField() = default; // Member Functions - //- Return true if running parallel + //- True if running parallel virtual bool coupled() const { - return Pstream::parRun(); + return UPstream::parRun(); } }; diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/processorCyclic/processorCyclicFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/processorCyclic/processorCyclicFvsPatchField.C index 69dda610a3..af904a50fb 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/processorCyclic/processorCyclicFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/processorCyclic/processorCyclicFvsPatchField.C @@ -122,11 +122,4 @@ Foam::processorCyclicFvsPatchField::processorCyclicFvsPatchField {} -// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // - -template -Foam::processorCyclicFvsPatchField::~processorCyclicFvsPatchField() -{} - - // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/processorCyclic/processorCyclicFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/processorCyclic/processorCyclicFvsPatchField.H index 4368b03621..8ebb8fbb21 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/processorCyclic/processorCyclicFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/processorCyclic/processorCyclicFvsPatchField.H @@ -27,15 +27,18 @@ Class Foam::processorCyclicFvsPatchField Description - Foam::processorCyclicFvsPatchField + This boundary condition enables processor communication across cyclic + patches. + + The "value" entry is MUST_READ. SourceFiles processorCyclicFvsPatchField.C \*---------------------------------------------------------------------------*/ -#ifndef processorCyclicFvsPatchField_H -#define processorCyclicFvsPatchField_H +#ifndef Foam_processorCyclicFvsPatchField_H +#define Foam_processorCyclicFvsPatchField_H #include "coupledFvsPatchField.H" #include "processorCyclicFvPatch.H" @@ -54,7 +57,7 @@ class processorCyclicFvsPatchField : public coupledFvsPatchField { - // Private data + // Private Data //- Local reference cast into the processor patch const processorCyclicFvPatch& procPatch_; @@ -83,7 +86,8 @@ public: const Field& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is MUST_READ. processorCyclicFvsPatchField ( const fvPatch&, @@ -91,8 +95,7 @@ public: const dictionary& ); - //- Construct by mapping given processorCyclicFvsPatchField onto a - // new patch + //- Construct by mapping given patch field onto a new patch processorCyclicFvsPatchField ( const processorCyclicFvsPatchField&, @@ -128,15 +131,15 @@ public: //- Destructor - virtual ~processorCyclicFvsPatchField(); + virtual ~processorCyclicFvsPatchField() = default; // Member Functions - //- Return true if running parallel + //- True if running parallel virtual bool coupled() const { - return Pstream::parRun(); + return UPstream::parRun(); } }; diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.C index 1f65f735ce..071abfefee 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,7 +49,7 @@ Foam::symmetryFvsPatchField::symmetryFvsPatchField const dictionary& dict ) : - fvsPatchField(p, iF, dict) + fvsPatchField(p, iF, dict, IOobjectOption::NO_READ) { if (!isType(p)) { @@ -83,16 +84,6 @@ Foam::symmetryFvsPatchField::symmetryFvsPatchField } -template -Foam::symmetryFvsPatchField::symmetryFvsPatchField -( - const symmetryFvsPatchField& ptf -) -: - fvsPatchField(ptf) -{} - - template Foam::symmetryFvsPatchField::symmetryFvsPatchField ( @@ -104,4 +95,14 @@ Foam::symmetryFvsPatchField::symmetryFvsPatchField {} +template +Foam::symmetryFvsPatchField::symmetryFvsPatchField +( + const symmetryFvsPatchField& ptf +) +: + symmetryFvsPatchField(ptf, ptf.internalField()) +{} + + // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.H index 4fa95f9680..4142b0d70f 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,15 +28,26 @@ Class Foam::symmetryFvsPatchField Description - Foam::symmetryFvsPatchField + This boundary condition enforces a symmetry constraint + + The "value" entry is NO_READ, NO_WRITE. + +Usage + Example of the boundary condition specification: + \verbatim + + { + type symmetry; + } + \endverbatim SourceFiles symmetryFvsPatchField.C \*---------------------------------------------------------------------------*/ -#ifndef symmetryFvsPatchField_H -#define symmetryFvsPatchField_H +#ifndef Foam_symmetryFvsPatchField_H +#define Foam_symmetryFvsPatchField_H #include "fvsPatchField.H" #include "symmetryFvPatch.H" @@ -54,7 +66,6 @@ class symmetryFvsPatchField : public fvsPatchField { - public: //- Runtime type information @@ -71,6 +82,7 @@ public: ); //- Construct from patch, internal field and dictionary + //- The "value" entry is NO_READ. symmetryFvsPatchField ( const fvPatch&, diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.C index 60bf14ab43..80d4b9378d 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2015 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,7 +49,7 @@ Foam::symmetryPlaneFvsPatchField::symmetryPlaneFvsPatchField const dictionary& dict ) : - fvsPatchField(p, iF, dict) + fvsPatchField(p, iF, dict, IOobjectOption::NO_READ) { if (!isType(p)) { @@ -83,16 +84,6 @@ Foam::symmetryPlaneFvsPatchField::symmetryPlaneFvsPatchField } -template -Foam::symmetryPlaneFvsPatchField::symmetryPlaneFvsPatchField -( - const symmetryPlaneFvsPatchField& ptf -) -: - fvsPatchField(ptf) -{} - - template Foam::symmetryPlaneFvsPatchField::symmetryPlaneFvsPatchField ( @@ -104,4 +95,14 @@ Foam::symmetryPlaneFvsPatchField::symmetryPlaneFvsPatchField {} +template +Foam::symmetryPlaneFvsPatchField::symmetryPlaneFvsPatchField +( + const symmetryPlaneFvsPatchField& ptf +) +: + symmetryPlaneFvsPatchField(ptf, ptf.internalField()) +{} + + // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.H index cf3f253e05..717506e082 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.H @@ -27,15 +27,26 @@ Class Foam::symmetryPlaneFvsPatchField Description - Foam::symmetryPlaneFvsPatchField + This boundary condition enforces a symmetryPlane constraint + + The "value" entry is NO_READ, NO_WRITE. + +Usage + Example of the boundary condition specification: + \verbatim + + { + type symmetryPlane; + } + \endverbatim SourceFiles symmetryPlaneFvsPatchField.C \*---------------------------------------------------------------------------*/ -#ifndef symmetryPlaneFvsPatchField_H -#define symmetryPlaneFvsPatchField_H +#ifndef Foam_symmetryPlaneFvsPatchField_H +#define Foam_symmetryPlaneFvsPatchField_H #include "fvsPatchField.H" #include "symmetryPlaneFvPatch.H" @@ -54,7 +65,6 @@ class symmetryPlaneFvsPatchField : public fvsPatchField { - public: //- Runtime type information @@ -70,7 +80,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is NO_READ. symmetryPlaneFvsPatchField ( const fvPatch&, @@ -78,8 +89,7 @@ public: const dictionary& ); - //- Construct by mapping given symmetryPlaneFvsPatchField - // onto a new patch + //- Construct by mapping given patch field onto a new patch symmetryPlaneFvsPatchField ( const symmetryPlaneFvsPatchField&, diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.C index 9c243442b5..df57e01f61 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,7 +49,7 @@ Foam::wedgeFvsPatchField::wedgeFvsPatchField const dictionary& dict ) : - fvsPatchField(p, iF, dict) + fvsPatchField(p, iF, dict, IOobjectOption::NO_READ) { if (!isType(p)) { @@ -83,16 +84,6 @@ Foam::wedgeFvsPatchField::wedgeFvsPatchField } -template -Foam::wedgeFvsPatchField::wedgeFvsPatchField -( - const wedgeFvsPatchField& ptf -) -: - fvsPatchField(ptf) -{} - - template Foam::wedgeFvsPatchField::wedgeFvsPatchField ( @@ -104,4 +95,14 @@ Foam::wedgeFvsPatchField::wedgeFvsPatchField {} +template +Foam::wedgeFvsPatchField::wedgeFvsPatchField +( + const wedgeFvsPatchField& ptf +) +: + wedgeFvsPatchField(ptf, ptf.internalField()) +{} + + // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.H index 9c5ce9eb72..aeb04ff0bc 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,15 +28,27 @@ Class Foam::wedgeFvsPatchField Description - Foam::wedgeFvsPatchField + This boundary condition is similar to the cyclic condition, except that + it is applied to 2-D geometries. + + The "value" entry is NO_READ, NO_WRITE. + +Usage + Example of the boundary condition specification: + \verbatim + + { + type wedge; + } + \endverbatim SourceFiles wedgeFvsPatchField.C \*---------------------------------------------------------------------------*/ -#ifndef wedgeFvsPatchField_H -#define wedgeFvsPatchField_H +#ifndef Foam_wedgeFvsPatchField_H +#define Foam_wedgeFvsPatchField_H #include "fvsPatchField.H" #include "wedgeFvPatch.H" @@ -54,7 +67,6 @@ class wedgeFvsPatchField : public fvsPatchField { - public: //- Runtime type information @@ -70,7 +82,8 @@ public: const DimensionedField& ); - //- Construct from patch, internal field and dictionary + //- Construct from patch, internal field and dictionary. + //- The "value" entry is NO_READ. wedgeFvsPatchField ( const fvPatch&, diff --git a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C index b197203cb2..027b488214 100644 --- a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C @@ -207,7 +207,6 @@ template void Foam::fvsPatchField::write(Ostream& os) const { os.writeEntry("type", type()); - Field::writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H index 26f2f4beb5..ddb7dfa8b6 100644 --- a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H @@ -343,13 +343,13 @@ public: const fvPatch& p, const DimensionedField& iF, const dictionary& dict, - const bool valueReqd + const bool needValue ) : fvsPatchField ( p, iF, dict, - (valueReqd? IOobjectOption::MUST_READ : IOobjectOption::NO_READ) + (needValue? IOobjectOption::MUST_READ : IOobjectOption::NO_READ) ) {} @@ -541,7 +541,7 @@ public: {} - //- Write + //- Write the patch "type" virtual void write(Ostream& os) const; //- Check against given patch field diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/specularRadiation/specularRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/specularRadiation/specularRadiationMixedFvPatchScalarField.C index d748553358..7b7f5c100c 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/specularRadiation/specularRadiationMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/specularRadiation/specularRadiationMixedFvPatchScalarField.C @@ -449,7 +449,7 @@ void specularRadiationMixedFvPatchScalarField::write(Ostream& os) const { mixedFvPatchScalarField::write(os); os.writeEntryIfDifferent("interpolate", false, interpolate_); - this->writeEntry("value", os); + this->writeValueEntry(os); } From f04ccef588da5ed28225e2071999df905b0e0f06 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 19 Apr 2024 11:17:43 +0200 Subject: [PATCH 2/2] ENH: improve code consistency for {cell,face,point}Mapper (#3147) - robuster and more reliable determination of inserted objects (previous code could produce false positives). Now also determine the number of inserted objects within the constructor (instead of simply storing a bool). This allows reuse in the address calculations to reduce overheads there. BUG: dodgy short-circuit logic for insertedObjectLabels() - as a quick short-circuit it previously created as demand-driven pointer with a zero elements. However, this meant that if this code was called first (before any other addressing), subsequent calls to the addressing would fail. BUG: bad logic and lookup for faAreaMapper (#3147) - was using labelHashSet but returning a bool and set using the addressing using the unfiltered objects! This is a latent bug since interpolated/inserted faces not currently supported anyhow. ENH: use std::unique_ptr for demand-driven data --- .../pointMeshMapper/pointBoundaryMeshMapper.H | 4 +- .../pointMesh/pointMeshMapper/pointMapper.C | 312 +++++++----- .../pointMesh/pointMeshMapper/pointMapper.H | 58 ++- .../pointMeshMapper/pointMeshMapper.H | 17 +- .../pointMeshMapper/pointPatchMapper.C | 54 +-- .../pointMeshMapper/pointPatchMapper.H | 21 +- .../mapPolyMesh/cellMapper/cellMapper.C | 445 +++++++++--------- .../mapPolyMesh/cellMapper/cellMapper.H | 55 +-- .../mapPolyMesh/faceMapper/faceMapper.C | 355 +++++++------- .../mapPolyMesh/faceMapper/faceMapper.H | 54 +-- .../meshes/polyMesh/mapPolyMesh/mapPolyMesh.C | 2 +- .../meshes/polyMesh/mapPolyMesh/mapPolyMesh.H | 94 ++-- .../mapPolyMesh/objectMap/objectMap.H | 49 +- .../mapPolyMesh/objectMap/objectMapI.H | 44 +- .../faMesh/faMeshMapper/faAreaMapper.C | 268 ++++------- .../faMesh/faMeshMapper/faAreaMapper.H | 34 +- .../faMeshMapper/faBoundaryMeshMapper.H | 4 +- .../faMesh/faMeshMapper/faEdgeMapper.C | 25 +- .../faMesh/faMeshMapper/faEdgeMapper.H | 47 +- .../faMesh/faMeshMapper/faMeshMapper.C | 10 +- .../faMesh/faMeshMapper/faMeshMapper.H | 6 +- .../faMesh/faMeshMapper/faPatchMapper.C | 23 +- .../faMesh/faMeshMapper/faPatchMapper.H | 21 +- .../fvMeshMapper/fvBoundaryMeshMapper.H | 4 +- .../fvMesh/fvMeshMapper/fvMeshMapper.H | 8 +- .../fvMesh/fvMeshMapper/fvPatchMapper.C | 93 ++-- .../fvMesh/fvMeshMapper/fvPatchMapper.H | 21 +- .../fvMesh/fvMeshMapper/fvSurfaceMapper.C | 114 ++--- .../fvMesh/fvMeshMapper/fvSurfaceMapper.H | 26 +- 29 files changed, 1089 insertions(+), 1179 deletions(-) diff --git a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointBoundaryMeshMapper.H b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointBoundaryMeshMapper.H index 6c155b5401..f45bc5942a 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointBoundaryMeshMapper.H +++ b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointBoundaryMeshMapper.H @@ -31,8 +31,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef pointBoundaryMeshMapper_H -#define pointBoundaryMeshMapper_H +#ifndef Foam_pointBoundaryMeshMapper_H +#define Foam_pointBoundaryMeshMapper_H #include "PtrList.H" #include "pointPatchMapper.H" diff --git a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMapper.C b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMapper.C index 3fba1b2c16..2daa81872c 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMapper.C +++ b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMapper.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,7 +27,6 @@ License \*---------------------------------------------------------------------------*/ #include "pointMapper.H" -#include "demandDrivenData.H" #include "pointMesh.H" #include "mapPolyMesh.H" @@ -37,9 +37,9 @@ void Foam::pointMapper::calcAddressing() const if ( directAddrPtr_ - || interpolationAddrPtr_ + || interpAddrPtr_ || weightsPtr_ - || insertedPointLabelsPtr_ + || insertedObjectsPtr_ ) { FatalErrorInFunction @@ -51,160 +51,226 @@ void Foam::pointMapper::calcAddressing() const { // Direct addressing, no weights - directAddrPtr_ = new labelList(mpm_.pointMap()); - labelList& directAddr = *directAddrPtr_; + directAddrPtr_ = std::make_unique + ( + // No retired points, so pointMap().size() == mapperLen_ anyhow + labelList::subList(mpm_.pointMap(), mapperLen_) + ); + auto& directAddr = *directAddrPtr_; - // Not necessary to resize the list as there are no retired points - // directAddr.setSize(pMesh_.size()); + insertedObjectsPtr_ = std::make_unique(); + auto& inserted = *insertedObjectsPtr_; - insertedPointLabelsPtr_ = new labelList(pMesh_.size()); - labelList& insertedPoints = *insertedPointLabelsPtr_; - - label nInsertedPoints = 0; - - forAll(directAddr, pointi) + // The nInsertedObjects_ already counted in the constructor + if (nInsertedObjects_) { - if (directAddr[pointi] < 0) - { - // Found inserted point - directAddr[pointi] = 0; - insertedPoints[nInsertedPoints] = pointi; - nInsertedPoints++; - } - } + inserted.resize(nInsertedObjects_); - insertedPoints.setSize(nInsertedPoints); + label nInserted = 0; + forAll(directAddr, i) + { + if (directAddr[i] < 0) + { + // Found inserted + directAddr[i] = 0; + inserted[nInserted] = i; + ++nInserted; + + // TBD: check (nInsertedObjects_ < nInserted)? + #ifdef FULLDEBUG + if (nInsertedObjects_ < nInserted) + { + FatalErrorInFunction + << "Unexpected insert of more than " + << nInsertedObjects_ << " items\n" + << abort(FatalError); + } + #endif + } + } + // TBD: check (nInserted < nInsertedObjects_)? + #ifdef FULLDEBUG + if (nInserted < nInsertedObjects_) + { + WarningInFunction + << "Found " << nInserted << " instead of " + << nInsertedObjects_ << " items to insert\n"; + } + #endif + // The resize should be unnecessary + inserted.resize(nInserted); + } } else { // Interpolative addressing - interpolationAddrPtr_ = new labelListList(pMesh_.size()); - labelListList& addr = *interpolationAddrPtr_; + interpAddrPtr_ = std::make_unique(mapperLen_); + auto& addr = *interpAddrPtr_; + + weightsPtr_ = std::make_unique(mapperLen_); + auto& wght = *weightsPtr_; + + + // Set the addressing and uniform weight + const auto setAddrWeights = [&] + ( + const List& maps, + const char * const nameOfMap + ) + { + for (const objectMap& map : maps) + { + // Get index, addressing + const label pointi = map.index(); + const labelList& mo = map.masterObjects(); + if (mo.empty()) continue; // safety + + if (addr[pointi].size()) + { + FatalErrorInFunction + << "Master point " << pointi + << " already mapped, cannot apply " + << nameOfMap + << flatOutput(mo) << abort(FatalError); + } + + // Map from masters, uniform weights + addr[pointi] = mo; + wght[pointi] = scalarList(mo.size(), 1.0/mo.size()); + } + }; - weightsPtr_ = new scalarListList(pMesh_.size()); - scalarListList& w = *weightsPtr_; // Points created from other points (i.e. points merged into it). - const List& cfc = mpm_.pointsFromPointsMap(); - forAll(cfc, cfcI) + setAddrWeights(mpm_.pointsFromPointsMap(), "point points"); + + + // Do mapped points. + // - may already have been set, so check if addressing still empty(). + { - // Get addressing - const labelList& mo = cfc[cfcI].masterObjects(); + const labelList& map = mpm_.pointMap(); - label pointi = cfc[cfcI].index(); - - if (addr[pointi].size()) + for (label pointi = 0; pointi < mapperLen_; ++pointi) { - FatalErrorInFunction - << "Master point " << pointi - << " mapped from points " << mo - << " already destination of mapping." << abort(FatalError); - } + const label mappedi = map[pointi]; - // Map from masters, uniform weights - addr[pointi] = mo; - w[pointi] = scalarList(mo.size(), 1.0/mo.size()); - } - - - // Do mapped points. Note that can already be set from pointsFromPoints - // so check if addressing size still zero. - - const labelList& cm = mpm_.pointMap(); - - forAll(cm, pointi) - { - if (cm[pointi] > -1 && addr[pointi].empty()) - { - // Mapped from a single point - addr[pointi] = labelList(1, cm[pointi]); - w[pointi] = scalarList(1, scalar(1)); + if (mappedi >= 0 && addr[pointi].empty()) + { + // Mapped from a single point + addr[pointi].resize(1, mappedi); + wght[pointi].resize(1, 1.0); + } } } // Grab inserted points (for them the size of addressing is still zero) - insertedPointLabelsPtr_ = new labelList(pMesh_.size()); - labelList& insertedPoints = *insertedPointLabelsPtr_; + insertedObjectsPtr_ = std::make_unique(); + auto& inserted = *insertedObjectsPtr_; - label nInsertedPoints = 0; - - forAll(addr, pointi) + // The nInsertedObjects_ already counted in the constructor + if (nInsertedObjects_) { - if (addr[pointi].empty()) + inserted.resize(nInsertedObjects_); + + label nInserted = 0; + forAll(addr, i) { - // Mapped from a dummy point. Take point 0 with weight 1. - addr[pointi] = labelList(1, Zero); - w[pointi] = scalarList(1, scalar(1)); + if (addr[i].empty()) + { + // Mapped from dummy point 0 + addr[i].resize(1, 0); + wght[i].resize(1, 1.0); - insertedPoints[nInsertedPoints] = pointi; - nInsertedPoints++; + inserted[nInserted] = i; + ++nInserted; + + // TBD: check (nInsertedObjects_ < nInserted)? + #ifdef FULLDEBUG + if (nInsertedObjects_ < nInserted) + { + FatalErrorInFunction + << "Unexpected insert of more than " + << nInsertedObjects_ << " items\n" + << abort(FatalError); + } + #endif + } } + // TBD: check (nInserted < nInsertedObjects_)? + #ifdef FULLDEBUG + if (nInserted < nInsertedObjects_) + { + WarningInFunction + << "Found " << nInserted << " instead of " + << nInsertedObjects_ << " items to insert\n"; + } + #endif + // The resize should be unnecessary + inserted.resize(nInserted); } - - insertedPoints.setSize(nInsertedPoints); } } -void Foam::pointMapper::clearOut() -{ - deleteDemandDrivenData(directAddrPtr_); - deleteDemandDrivenData(interpolationAddrPtr_); - deleteDemandDrivenData(weightsPtr_); - deleteDemandDrivenData(insertedPointLabelsPtr_); -} +// void Foam::pointMapper::clearOut() +// { +// directAddrPtr_.reset(nullptr); +// interpAddrPtr_.reset(nullptr); +// weightsPtr_.reset(nullptr); +// insertedObjectsPtr_.reset(nullptr); +// } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::pointMapper::pointMapper(const pointMesh& pMesh, const mapPolyMesh& mpm) : - pMesh_(pMesh), mpm_(mpm), - insertedPoints_(true), - direct_(false), - directAddrPtr_(nullptr), - interpolationAddrPtr_(nullptr), - weightsPtr_(nullptr), - insertedPointLabelsPtr_(nullptr) + mapperLen_(pMesh.size()), + nInsertedObjects_(0), + direct_ + ( + // Mapping without interpolation? + mpm.pointsFromPointsMap().empty() + ) { - // Check for possibility of direct mapping - if (mpm_.pointsFromPointsMap().empty()) + const auto& directMap = mpm_.pointMap(); + + if (!mapperLen_) { + // Empty mesh direct_ = true; + nInsertedObjects_ = 0; + } + else if (direct_) + { + // Number of inserted points (-ve values) + nInsertedObjects_ = std::count_if + ( + directMap.cbegin(), + directMap.cbegin(mapperLen_), + [](label i) { return (i < 0); } + ); } else { - direct_ = false; - } + // Check if there are inserted points with no owner + // (check all lists) - // Check for inserted points - if (direct_ && (mpm_.pointMap().empty() || min(mpm_.pointMap()) > -1)) - { - insertedPoints_ = false; - } - else - { - //Check if there are inserted points with no owner + bitSet unmapped(mapperLen_, true); - // Make a copy of the point map, add the entries for points from points - // and check for left-overs - labelList cm(pMesh_.size(), -1); + unmapped.unset(directMap); // direct mapped - const List& cfc = mpm_.pointsFromPointsMap(); - - forAll(cfc, cfcI) + for (const objectMap& map : mpm_.pointsFromPointsMap()) { - cm[cfc[cfcI].index()] = 0; + if (!map.empty()) unmapped.unset(map.index()); } - if (min(cm) < 0) - { - insertedPoints_ = true; - } + nInsertedObjects_ = label(unmapped.count()); } } @@ -212,15 +278,14 @@ Foam::pointMapper::pointMapper(const pointMesh& pMesh, const mapPolyMesh& mpm) // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::pointMapper::~pointMapper() -{ - clearOut(); -} +{} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::label Foam::pointMapper::size() const { + // OR: return mapperLen_; return mpm_.pointMap().size(); } @@ -266,12 +331,12 @@ const Foam::labelListList& Foam::pointMapper::addressing() const << abort(FatalError); } - if (!interpolationAddrPtr_) + if (!interpAddrPtr_) { calcAddressing(); } - return *interpolationAddrPtr_; + return *interpAddrPtr_; } @@ -295,30 +360,19 @@ const Foam::scalarListList& Foam::pointMapper::weights() const const Foam::labelList& Foam::pointMapper::insertedObjectLabels() const { - if (!insertedPointLabelsPtr_) + if (!insertedObjectsPtr_) { - if (!insertedObjects()) + if (!nInsertedObjects_) { - // There are no inserted points - insertedPointLabelsPtr_ = new labelList(0); - } - else - { - calcAddressing(); + // No inserted objects will be created + return labelList::null(); } + + calcAddressing(); } - return *insertedPointLabelsPtr_; + return *insertedObjectsPtr_; } -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - - // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMapper.H b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMapper.H index 1e33711871..7783e6b361 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMapper.H +++ b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMapper.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2013 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,8 +37,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef pointMapper_H -#define pointMapper_H +#ifndef Foam_pointMapper_H +#define Foam_pointMapper_H #include "morphFieldMapper.H" @@ -46,10 +47,9 @@ SourceFiles namespace Foam { -// Forward declaration of classes -class pointMesh; +// Forward Declarations class mapPolyMesh; -class polyMesh; +class pointMesh; /*---------------------------------------------------------------------------*\ Class pointMapper Declaration @@ -59,38 +59,45 @@ class pointMapper : public morphFieldMapper { - // Private data - - //- Reference to pointMesh - const pointMesh& pMesh_; + // Private Data //- Reference to mapPolyMesh const mapPolyMesh& mpm_; - //- Are there any inserted (unmapped) points - bool insertedPoints_; + //- The size of the mapper = pointMesh::size() + const label mapperLen_; + + //- Number of inserted (unmapped) points + label nInsertedObjects_; //- Is the mapping direct bool direct_; - // Demand-driven private data + // Demand-Driven Data //- Direct addressing (only one for of addressing is used) - mutable labelList* directAddrPtr_; + mutable std::unique_ptr directAddrPtr_; //- Interpolated addressing (only one for of addressing is used) - mutable labelListList* interpolationAddrPtr_; + mutable std::unique_ptr interpAddrPtr_; //- Interpolation weights - mutable scalarListList* weightsPtr_; + mutable std::unique_ptr weightsPtr_; //- Inserted points - mutable labelList* insertedPointLabelsPtr_; + mutable std::unique_ptr insertedObjectsPtr_; // Private Member Functions + //- Calculate addressing for mapping with inserted points + void calcAddressing() const; + +public: + + // Generated Methods + //- No copy construct pointMapper(const pointMapper&) = delete; @@ -98,28 +105,20 @@ class pointMapper void operator=(const pointMapper&) = delete; - //- Calculate addressing for mapping with inserted points - void calcAddressing() const; - - //- Clear out local storage - void clearOut(); - - -public: - // Constructors //- Construct from mapPolyMesh pointMapper(const pointMesh&, const mapPolyMesh& mpm); + //- Destructor virtual ~pointMapper(); // Member Functions - //- Return size + //- The mapper size virtual label size() const; //- Return size before mapping @@ -131,8 +130,7 @@ public: return direct_; } - //- Are there unmapped values? I.e. do all size() elements get - // get value + //- Are there unmapped values? i.e. do all size() elements get value virtual bool hasUnmapped() const { return insertedObjects(); @@ -148,9 +146,9 @@ public: virtual const scalarListList& weights() const; //- Are there any inserted points - bool insertedObjects() const + bool insertedObjects() const noexcept { - return insertedPoints_; + return bool(nInsertedObjects_); } //- Return list of inserted points diff --git a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMeshMapper.H b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMeshMapper.H index 54e18c664e..f6cb259262 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMeshMapper.H +++ b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMeshMapper.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef pointMeshMapper_H -#define pointMeshMapper_H +#ifndef Foam_pointMeshMapper_H +#define Foam_pointMeshMapper_H #include "pointMapper.H" #include "pointBoundaryMeshMapper.H" @@ -46,7 +46,7 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward Declarations class pointMesh; class mapPolyMesh; @@ -56,7 +56,7 @@ class mapPolyMesh; class pointMeshMapper { - // Private data + // Private Data //- Reference to mesh const pointMesh& mesh_; @@ -92,28 +92,27 @@ public: // Member Functions - //- Return reference to mesh fields belong to - const pointMesh& mesh() const + const pointMesh& mesh() const noexcept { return mesh_; } //- Return reference to objectRegistry storing fields. Can be // removed once fields stored on pointMesh. - const objectRegistry& thisDb() const + const objectRegistry& thisDb() const noexcept { return mesh_(); } //- Return point mapper - const morphFieldMapper& pointMap() const + const morphFieldMapper& pointMap() const noexcept { return pointMap_; } //- Return boundary mapper - const pointBoundaryMeshMapper& boundaryMap() const + const pointBoundaryMeshMapper& boundaryMap() const noexcept { return boundaryMap_; } diff --git a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.C b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.C index e9a18985c0..2e6a2d7c4f 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.C +++ b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,7 +30,6 @@ License #include "pointPatch.H" #include "mapPolyMesh.H" #include "faceMapper.H" -#include "demandDrivenData.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -38,7 +38,7 @@ void Foam::pointPatchMapper::calcAddressing() const if ( directAddrPtr_ - || interpolationAddrPtr_ + || interpAddrPtr_ || weightsPtr_ ) { @@ -52,8 +52,11 @@ void Foam::pointPatchMapper::calcAddressing() const if (direct()) { // Direct mapping. - directAddrPtr_ = new labelList(mpm_.patchPointMap()[patch_.index()]); - labelList& addr = *directAddrPtr_; + directAddrPtr_ = std::make_unique + ( + mpm_.patchPointMap()[patch_.index()] + ); + auto& addr = *directAddrPtr_; forAll(addr, i) { @@ -73,11 +76,11 @@ void Foam::pointPatchMapper::calcAddressing() const // patch points. Problem is we don't know what points were in the patch // for points that were merged. - interpolationAddrPtr_ = new labelListList(size()); - labelListList& addr = *interpolationAddrPtr_; + interpAddrPtr_ = std::make_unique(size()); + auto& addr = *interpAddrPtr_; - weightsPtr_ = new scalarListList(addr.size()); - scalarListList& w = *weightsPtr_; + weightsPtr_ = std::make_unique(addr.size()); + auto& wght = *weightsPtr_; const labelList& ppm = mpm_.patchPointMap()[patch_.index()]; @@ -85,15 +88,15 @@ void Foam::pointPatchMapper::calcAddressing() const { if (ppm[i] >= 0) { - addr[i] = labelList(1, ppm[i]); - w[i] = scalarList(1, scalar(1)); + addr[i].resize(1, ppm[i]); + wght[i].resize(1, 1.0); } else { // Inserted point. ///// Map from point0 (arbitrary choice) - //addr[i] = labelList(1, Zero); - //w[i] = scalarList(1, scalar(1)); + //addr[i].resize(1, 0); + //wght[i].resize(1, 1.0); hasUnmapped_ = true; } } @@ -101,13 +104,13 @@ void Foam::pointPatchMapper::calcAddressing() const } -void Foam::pointPatchMapper::clearOut() -{ - deleteDemandDrivenData(directAddrPtr_); - deleteDemandDrivenData(interpolationAddrPtr_); - deleteDemandDrivenData(weightsPtr_); - hasUnmapped_ = false; -} +// void Foam::pointPatchMapper::clearOut() +// { +// directAddrPtr_.reset(nullptr); +// interpAddrPtr_.reset(nullptr); +// weightsPtr_.reset(nullptr); +// hasUnmapped_ = false; +// } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -129,19 +132,14 @@ Foam::pointPatchMapper::pointPatchMapper ? mpm_.oldPatchNMeshPoints()[patch_.index()] : 0 ), - hasUnmapped_(false), - directAddrPtr_(nullptr), - interpolationAddrPtr_(nullptr), - weightsPtr_(nullptr) + hasUnmapped_(false) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::pointPatchMapper::~pointPatchMapper() -{ - clearOut(); -} +{} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -173,12 +171,12 @@ const Foam::labelListList& Foam::pointPatchMapper::addressing() const << abort(FatalError); } - if (!interpolationAddrPtr_) + if (!interpAddrPtr_) { calcAddressing(); } - return *interpolationAddrPtr_; + return *interpAddrPtr_; } diff --git a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.H b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.H index c79491970f..e9570dbad3 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.H +++ b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2013 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef pointPatchMapper_H -#define pointPatchMapper_H +#ifndef Foam_pointPatchMapper_H +#define Foam_pointPatchMapper_H #include "pointMapper.H" #include "pointPatchFieldMapper.H" @@ -47,7 +48,7 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward Declarations class pointPatch; class mapPolyMesh; @@ -59,7 +60,7 @@ class pointPatchMapper : public pointPatchFieldMapper { - // Private data + // Private Data //- Reference to patch const pointPatch& patch_; @@ -74,18 +75,18 @@ class pointPatchMapper const label sizeBeforeMapping_; - // Demand-driven private data + // Demand-driven Data mutable bool hasUnmapped_; //- Direct addressing (only one for of addressing is used) - mutable labelList* directAddrPtr_; + mutable std::unique_ptr directAddrPtr_; //- Interpolated addressing (only one for of addressing is used) - mutable labelListList* interpolationAddrPtr_; + mutable std::unique_ptr interpAddrPtr_; //- Interpolation weights - mutable scalarListList* weightsPtr_; + mutable std::unique_ptr weightsPtr_; // Private Member Functions @@ -100,9 +101,6 @@ class pointPatchMapper //- Calculate addressing for mapping with inserted cells void calcAddressing() const; - //- Clear out local storage - void clearOut(); - public: @@ -156,7 +154,6 @@ public: //- Return interpolaion weights virtual const scalarListList& weights() const; - }; diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/cellMapper/cellMapper.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/cellMapper/cellMapper.C index fd277b511d..4ac6c44ad1 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/cellMapper/cellMapper.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/cellMapper/cellMapper.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,7 +27,6 @@ License \*---------------------------------------------------------------------------*/ #include "cellMapper.H" -#include "demandDrivenData.H" #include "polyMesh.H" #include "mapPolyMesh.H" @@ -37,9 +37,9 @@ void Foam::cellMapper::calcAddressing() const if ( directAddrPtr_ - || interpolationAddrPtr_ + || interpAddrPtr_ || weightsPtr_ - || insertedCellLabelsPtr_ + || insertedObjectsPtr_ ) { FatalErrorInFunction @@ -51,129 +51,105 @@ void Foam::cellMapper::calcAddressing() const { // Direct addressing, no weights - directAddrPtr_ = new labelList(mpm_.cellMap()); - labelList& directAddr = *directAddrPtr_; + directAddrPtr_ = std::make_unique + ( + // No retired cells, so cellMap().size() == mapperLen_ anyhow + labelList::subList(mpm_.cellMap(), mapperLen_) + ); + auto& directAddr = *directAddrPtr_; - // Not necessary to resize the list as there are no retired cells - // directAddr.setSize(mesh_.nCells()); + insertedObjectsPtr_ = std::make_unique(); + auto& inserted = *insertedObjectsPtr_; - insertedCellLabelsPtr_ = new labelList(mesh_.nCells()); - labelList& insertedCells = *insertedCellLabelsPtr_; - - label nInsertedCells = 0; - - forAll(directAddr, celli) + // The nInsertedObjects_ already counted in the constructor + if (nInsertedObjects_) { - if (directAddr[celli] < 0) - { - // Found inserted cell - directAddr[celli] = 0; - insertedCells[nInsertedCells] = celli; - nInsertedCells++; - } - } + inserted.resize(nInsertedObjects_); - insertedCells.setSize(nInsertedCells); + label nInserted = 0; + forAll(directAddr, i) + { + if (directAddr[i] < 0) + { + // Found inserted + directAddr[i] = 0; + inserted[nInserted] = i; + ++nInserted; + + // TBD: check (nInsertedObjects_ < nInserted)? + #ifdef FULLDEBUG + if (nInsertedObjects_ < nInserted) + { + FatalErrorInFunction + << "Unexpected insert of more than " + << nInsertedObjects_ << " items\n" + << abort(FatalError); + } + #endif + } + } + // TBD: check (nInserted < nInsertedObjects_)? + #ifdef FULLDEBUG + if (nInserted < nInsertedObjects_) + { + WarningInFunction + << "Found " << nInserted << " instead of " + << nInsertedObjects_ << " items to insert\n"; + } + #endif + // The resize should be unnecessary + inserted.resize(nInserted); + } } else { // Interpolative addressing - interpolationAddrPtr_ = new labelListList(mesh_.nCells()); - labelListList& addr = *interpolationAddrPtr_; + interpAddrPtr_ = std::make_unique(mapperLen_); + auto& addr = *interpAddrPtr_; - weightsPtr_ = new scalarListList(mesh_.nCells()); - scalarListList& w = *weightsPtr_; + weightsPtr_ = std::make_unique(mapperLen_); + auto& wght = *weightsPtr_; - const List& cfp = mpm_.cellsFromPointsMap(); - forAll(cfp, cfpI) + // Set the addressing and uniform weight + const auto setAddrWeights = [&] + ( + const List& maps, + const char * const nameOfMap + ) { - // Get addressing - const labelList& mo = cfp[cfpI].masterObjects(); - - label celli = cfp[cfpI].index(); - - if (addr[celli].size()) + for (const objectMap& map : maps) { - FatalErrorInFunction - << "Master cell " << celli - << " mapped from point cells " << mo - << " already destination of mapping." << abort(FatalError); + // Get index, addressing + const label celli = map.index(); + const labelList& mo = map.masterObjects(); + if (mo.empty()) continue; // safety + + if (addr[celli].size()) + { + FatalErrorInFunction + << "Master cell " << celli + << " already mapped, cannot apply " + << nameOfMap + << flatOutput(mo) << abort(FatalError); + } + + // Map from masters, uniform weights + addr[celli] = mo; + wght[celli] = scalarList(mo.size(), 1.0/mo.size()); } + }; - // Map from masters, uniform weights - addr[celli] = mo; - w[celli] = scalarList(mo.size(), 1.0/mo.size()); - } - const List& cfe = mpm_.cellsFromEdgesMap(); - - forAll(cfe, cfeI) - { - // Get addressing - const labelList& mo = cfe[cfeI].masterObjects(); - - label celli = cfe[cfeI].index(); - - if (addr[celli].size()) - { - FatalErrorInFunction - << "Master cell " << celli - << " mapped from edge cells " << mo - << " already destination of mapping." << abort(FatalError); - } - - // Map from masters, uniform weights - addr[celli] = mo; - w[celli] = scalarList(mo.size(), 1.0/mo.size()); - } - - const List& cff = mpm_.cellsFromFacesMap(); - - forAll(cff, cffI) - { - // Get addressing - const labelList& mo = cff[cffI].masterObjects(); - - label celli = cff[cffI].index(); - - if (addr[celli].size()) - { - FatalErrorInFunction - << "Master cell " << celli - << " mapped from face cells " << mo - << " already destination of mapping." << abort(FatalError); - } - - // Map from masters, uniform weights - addr[celli] = mo; - w[celli] = scalarList(mo.size(), 1.0/mo.size()); - } + setAddrWeights(mpm_.cellsFromPointsMap(), "point cells"); + setAddrWeights(mpm_.cellsFromEdgesMap(), "edge cells"); + setAddrWeights(mpm_.cellsFromFacesMap(), "face cells"); // Volume conservative mapping if possible - const List& cfc = mpm_.cellsFromCellsMap(); - - forAll(cfc, cfcI) - { - // Get addressing - const labelList& mo = cfc[cfcI].masterObjects(); - - label celli = cfc[cfcI].index(); - - if (addr[celli].size()) - { - FatalErrorInFunction - << "Master cell " << celli - << " mapped from cell cells " << mo - << " already destination of mapping." - << abort(FatalError); - } - - // Map from masters - addr[celli] = mo; - } + const List& cellsFromCells = mpm_.cellsFromCellsMap(); + setAddrWeights(cellsFromCells, "cell cells"); if (mpm_.hasOldCellVolumes()) { @@ -185,182 +161,188 @@ void Foam::cellMapper::calcAddressing() const { FatalErrorInFunction << "cellVolumes size " << V.size() - << " is not the old number of cells " << sizeBeforeMapping() + << " != old number of cells " << sizeBeforeMapping() << ". Are your cellVolumes already mapped?" << " (new number of cells " << size() << ")" << abort(FatalError); } - forAll(cfc, cfcI) + for (const auto& map : cellsFromCells) { - const labelList& mo = cfc[cfcI].masterObjects(); + // Get index, addressing + const label celli = map.index(); + const labelList& mo = map.masterObjects(); + if (mo.empty()) continue; // safety - label celli = cfc[cfcI].index(); + // wght[celli] is already sized and uniform weighted + auto& wght_cell = wght[celli]; - w[celli].setSize(mo.size()); - - if (mo.size()) + scalar sumV = 0; + forAll(mo, ci) { - scalar sumV = 0; - forAll(mo, ci) + wght_cell[ci] = V[mo[ci]]; + sumV += V[mo[ci]]; + } + if (sumV > VSMALL) + { + for (auto& w : wght_cell) { - w[celli][ci] = V[mo[ci]]; - sumV += V[mo[ci]]; - } - if (sumV > VSMALL) - { - forAll(mo, ci) - { - w[celli][ci] /= sumV; - } - } - else - { - // Exception: zero volume. Use uniform mapping - w[celli] = scalarList(mo.size(), 1.0/mo.size()); + w /= sumV; } } + else + { + // Exception: zero volume. Use uniform mapping + wght_cell = (1.0/mo.size()); + } } } - else + + + // Do mapped cells. + // - may already have been set, so check if addressing still empty(). + { - // Uniform weighted + const labelList& map = mpm_.cellMap(); - forAll(cfc, cfcI) + // The cellMap.size() == nCells() anyhow + for (label celli = 0; celli < mapperLen_; ++celli) { - const labelList& mo = cfc[cfcI].masterObjects(); + const label mappedi = map[celli]; - label celli = cfc[cfcI].index(); - - w[celli] = scalarList(mo.size(), 1.0/mo.size()); + if (mappedi >= 0 && addr[celli].empty()) + { + // Mapped from a single cell + addr[celli].resize(1, mappedi); + wght[celli].resize(1, 1.0); + } } } - // Do mapped faces. Note that can already be set from cellsFromCells - // so check if addressing size still zero. - - const labelList& cm = mpm_.cellMap(); - - forAll(cm, celli) - { - if (cm[celli] > -1 && addr[celli].empty()) - { - // Mapped from a single cell - addr[celli] = labelList(1, cm[celli]); - w[celli] = scalarList(1, 1.0); - } - } - // Grab inserted points (for them the size of addressing is still zero) - insertedCellLabelsPtr_ = new labelList(mesh_.nCells()); - labelList& insertedCells = *insertedCellLabelsPtr_; + insertedObjectsPtr_ = std::make_unique(); + auto& inserted = *insertedObjectsPtr_; - label nInsertedCells = 0; - - forAll(addr, celli) + // The nInsertedObjects_ already counted in the constructor + if (nInsertedObjects_) { - if (addr[celli].empty()) + inserted.resize(nInsertedObjects_); + + label nInserted = 0; + forAll(addr, i) { - // Mapped from a dummy cell - addr[celli] = labelList(1, Zero); - w[celli] = scalarList(1, scalar(1)); + if (addr[i].empty()) + { + // Mapped from dummy cell 0 + addr[i].resize(1, 0); + wght[i].resize(1, 1.0); - insertedCells[nInsertedCells] = celli; - nInsertedCells++; + inserted[nInserted] = i; + ++nInserted; + + // TBD: check (nInsertedObjects_ < nInserted)? + #ifdef FULLDEBUG + if (nInsertedObjects_ < nInserted) + { + FatalErrorInFunction + << "Unexpected insert of more than " + << nInsertedObjects_ << " items\n" + << abort(FatalError); + } + #endif + } } + // TBD: check (nInserted < nInsertedObjects_)? + #ifdef FULLDEBUG + if (nInserted < nInsertedObjects_) + { + WarningInFunction + << "Found " << nInserted << " instead of " + << nInsertedObjects_ << " items to insert\n"; + } + #endif + // The resize should be unnecessary + inserted.resize(nInserted); } - - insertedCells.setSize(nInsertedCells); } } -void Foam::cellMapper::clearOut() -{ - deleteDemandDrivenData(directAddrPtr_); - deleteDemandDrivenData(interpolationAddrPtr_); - deleteDemandDrivenData(weightsPtr_); - deleteDemandDrivenData(insertedCellLabelsPtr_); -} +// void Foam::cellMapper::clearOut() +// { +// directAddrPtr_.reset(nullptr); +// interpAddrPtr_.reset(nullptr); +// weightsPtr_.reset(nullptr); +// insertedObjectsPtr_.reset(nullptr); +// } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::cellMapper::cellMapper(const mapPolyMesh& mpm) : - mesh_(mpm.mesh()), mpm_(mpm), - insertedCells_(true), - direct_(false), - directAddrPtr_(nullptr), - interpolationAddrPtr_(nullptr), - weightsPtr_(nullptr), - insertedCellLabelsPtr_(nullptr) -{ - // Check for possibility of direct mapping - if + mapperLen_(mpm.mesh().nCells()), + nInsertedObjects_(0), + direct_ ( - mpm_.cellsFromPointsMap().empty() - && mpm_.cellsFromEdgesMap().empty() - && mpm_.cellsFromFacesMap().empty() - && mpm_.cellsFromCellsMap().empty() + // Mapping without interpolation? + mpm.cellsFromPointsMap().empty() + && mpm.cellsFromEdgesMap().empty() + && mpm.cellsFromFacesMap().empty() + && mpm.cellsFromCellsMap().empty() ) +{ + const auto& directMap = mpm_.cellMap(); + + if (!mapperLen_) { + // Empty mesh direct_ = true; + nInsertedObjects_ = 0; + } + else if (direct_) + { + // Number of inserted cells (-ve values) + nInsertedObjects_ = std::count_if + ( + directMap.cbegin(), + directMap.cbegin(mapperLen_), + [](label i) { return (i < 0); } + ); } else { - direct_ = false; - } + // Check if there are inserted cells with no owner + // (check all lists) - // Check for inserted cells - if (direct_ && (mpm_.cellMap().empty() || min(mpm_.cellMap()) > -1)) - { - insertedCells_ = false; - } - else - { - // Need to check all 3 lists to see if there are inserted cells - // with no owner + bitSet unmapped(mapperLen_, true); - // Make a copy of the cell map, add the entried for cells from points, - // cells from edges and cells from faces and check for left-overs - labelList cm(mesh_.nCells(), -1); + unmapped.unset(directMap); // direct mapped - const List& cfp = mpm_.cellsFromPointsMap(); - - forAll(cfp, cfpI) + for (const auto& map : mpm_.cellsFromPointsMap()) { - cm[cfp[cfpI].index()] = 0; + if (!map.empty()) unmapped.unset(map.index()); } - const List& cfe = mpm_.cellsFromEdgesMap(); - - forAll(cfe, cfeI) + for (const auto& map : mpm_.cellsFromEdgesMap()) { - cm[cfe[cfeI].index()] = 0; + if (!map.empty()) unmapped.unset(map.index()); } - const List& cff = mpm_.cellsFromFacesMap(); - - forAll(cff, cffI) + for (const auto& map : mpm_.cellsFromFacesMap()) { - cm[cff[cffI].index()] = 0; + if (!map.empty()) unmapped.unset(map.index()); } - const List& cfc = mpm_.cellsFromCellsMap(); - - forAll(cfc, cfcI) + for (const auto& map : mpm_.cellsFromCellsMap()) { - cm[cfc[cfcI].index()] = 0; + if (!map.empty()) unmapped.unset(map.index()); } - if (min(cm) < 0) - { - insertedCells_ = true; - } + nInsertedObjects_ = label(unmapped.count()); } } @@ -368,15 +350,14 @@ Foam::cellMapper::cellMapper(const mapPolyMesh& mpm) // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::cellMapper::~cellMapper() -{ - clearOut(); -} +{} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::label Foam::cellMapper::size() const { + // OR: return mapperLen_; return mpm_.cellMap().size(); } @@ -422,12 +403,12 @@ const Foam::labelListList& Foam::cellMapper::addressing() const << abort(FatalError); } - if (!interpolationAddrPtr_) + if (!interpAddrPtr_) { calcAddressing(); } - return *interpolationAddrPtr_; + return *interpAddrPtr_; } @@ -451,20 +432,18 @@ const Foam::scalarListList& Foam::cellMapper::weights() const const Foam::labelList& Foam::cellMapper::insertedObjectLabels() const { - if (!insertedCellLabelsPtr_) + if (!insertedObjectsPtr_) { - if (!insertedObjects()) + if (!nInsertedObjects_) { - // There are no inserted cells - insertedCellLabelsPtr_ = new labelList(0); - } - else - { - calcAddressing(); + // No inserted objects will be created + return labelList::null(); } + + calcAddressing(); } - return *insertedCellLabelsPtr_; + return *insertedObjectsPtr_; } diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/cellMapper/cellMapper.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/cellMapper/cellMapper.H index 60eaedd82a..649b70dab9 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/cellMapper/cellMapper.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/cellMapper/cellMapper.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2013 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,8 +37,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef cellMapper_H -#define cellMapper_H +#ifndef Foam_cellMapper_H +#define Foam_cellMapper_H #include "morphFieldMapper.H" @@ -46,8 +47,7 @@ SourceFiles namespace Foam { -// Forward declaration of classes -class polyMesh; +// Forward Declarations class mapPolyMesh; /*---------------------------------------------------------------------------*\ @@ -58,38 +58,45 @@ class cellMapper : public morphFieldMapper { - // Private data - - //- Reference to polyMesh - const polyMesh& mesh_; + // Private Data //- Reference to mapPolyMesh const mapPolyMesh& mpm_; - //- Are there any inserted (unmapped) cells - bool insertedCells_; + //- The size of the mapper = polyMesh::nCells() + const label mapperLen_; + + //- Number of inserted (unmapped) cells + label nInsertedObjects_; //- Is the mapping direct bool direct_; - // Demand-driven private data + // Demand-Driven Data //- Direct addressing (only one for of addressing is used) - mutable labelList* directAddrPtr_; + mutable std::unique_ptr directAddrPtr_; //- Interpolated addressing (only one for of addressing is used) - mutable labelListList* interpolationAddrPtr_; + mutable std::unique_ptr interpAddrPtr_; //- Interpolation weights - mutable scalarListList* weightsPtr_; + mutable std::unique_ptr weightsPtr_; //- Inserted cells - mutable labelList* insertedCellLabelsPtr_; + mutable std::unique_ptr insertedObjectsPtr_; // Private Member Functions + //- Calculate addressing for mapping with inserted cells + void calcAddressing() const; + +public: + + // Generated Methods + //- No copy construct cellMapper(const cellMapper&) = delete; @@ -97,21 +104,10 @@ class cellMapper void operator=(const cellMapper&) = delete; - //- Calculate addressing for mapping with inserted cells - void calcAddressing() const; - - //- Clear out local storage - void clearOut(); - - -public: - - // Static data members - // Constructors //- Construct from mapPolyMesh - cellMapper(const mapPolyMesh& mpm); + explicit cellMapper(const mapPolyMesh& mpm); //- Destructor @@ -120,7 +116,7 @@ public: // Member Functions - //- Return size + //- The mapper size virtual label size() const; //- Return size before mapping @@ -132,6 +128,7 @@ public: return direct_; } + //- Are there unmapped values? virtual bool hasUnmapped() const { return insertedObjects(); @@ -149,7 +146,7 @@ public: //- Are there any inserted cells virtual bool insertedObjects() const { - return insertedCells_; + return bool(nInsertedObjects_); } //- Return list of inserted cells diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.C index 7745f65904..d638fe3efc 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,7 +27,6 @@ License \*---------------------------------------------------------------------------*/ #include "faceMapper.H" -#include "demandDrivenData.H" #include "polyMesh.H" #include "mapPolyMesh.H" @@ -37,9 +37,9 @@ void Foam::faceMapper::calcAddressing() const if ( directAddrPtr_ - || interpolationAddrPtr_ + || interpAddrPtr_ || weightsPtr_ - || insertedFaceLabelsPtr_ + || insertedObjectsPtr_ ) { FatalErrorInFunction @@ -51,223 +51,240 @@ void Foam::faceMapper::calcAddressing() const { // Direct addressing, no weights - directAddrPtr_ = new labelList(mpm_.faceMap()); - labelList& directAddr = *directAddrPtr_; + // Restrict addressing list to contain only live faces + directAddrPtr_ = std::make_unique + ( + labelList::subList(mpm_.faceMap(), mapperLen_) + ); + auto& directAddr = *directAddrPtr_; - // Reset the size of addressing list to contain only live faces - directAddr.setSize(mesh_.nFaces()); + insertedObjectsPtr_ = std::make_unique(); + auto& inserted = *insertedObjectsPtr_; - insertedFaceLabelsPtr_ = new labelList(mesh_.nFaces()); - labelList& insertedFaces = *insertedFaceLabelsPtr_; - - label nInsertedFaces = 0; - - forAll(directAddr, facei) + // The nInsertedObjects_ already counted in the constructor + if (nInsertedObjects_) { - if (directAddr[facei] < 0) - { - // Found inserted face - directAddr[facei] = 0; - insertedFaces[nInsertedFaces] = facei; - nInsertedFaces++; - } - } + inserted.resize(nInsertedObjects_); - insertedFaces.setSize(nInsertedFaces); + label nInserted = 0; + forAll(directAddr, i) + { + if (directAddr[i] < 0) + { + // Found inserted + directAddr[i] = 0; + inserted[nInserted] = i; + ++nInserted; + + // TBD: check (nInsertedObjects_ < nInserted)? + #ifdef FULLDEBUG + if (nInsertedObjects_ < nInserted) + { + FatalErrorInFunction + << "Unexpected insert of more than " + << nInsertedObjects_ << " items\n" + << abort(FatalError); + } + #endif + } + } + // TBD: check (nInserted < nInsertedObjects_)? + #ifdef FULLDEBUG + if (nInserted < nInsertedObjects_) + { + WarningInFunction + << "Found " << nInserted << " instead of " + << nInsertedObjects_ << " items to insert\n"; + } + #endif + // The resize should be unnecessary + inserted.resize(nInserted); + } } else { // Interpolative addressing - interpolationAddrPtr_ = new labelListList(mesh_.nFaces()); - labelListList& addr = *interpolationAddrPtr_; + interpAddrPtr_ = std::make_unique(mapperLen_); + auto& addr = *interpAddrPtr_; - weightsPtr_ = new scalarListList(mesh_.nFaces()); - scalarListList& w = *weightsPtr_; + weightsPtr_ = std::make_unique(mapperLen_); + auto& wght = *weightsPtr_; - const List& ffp = mpm_.facesFromPointsMap(); - forAll(ffp, ffpI) + // Set the addressing and uniform weight + const auto setAddrWeights = [&] + ( + const List& maps, + const char * const nameOfMap + ) { - // Get addressing - const labelList& mo = ffp[ffpI].masterObjects(); - - label facei = ffp[ffpI].index(); - - if (addr[facei].size()) + for (const objectMap& map : maps) { - FatalErrorInFunction - << "Master face " << facei - << " mapped from point faces " << mo - << " already destination of mapping." << abort(FatalError); + // Get index, addressing + const label facei = map.index(); + const labelList& mo = map.masterObjects(); + if (mo.empty()) continue; // safety + + if (addr[facei].size()) + { + FatalErrorInFunction + << "Master face " << facei + << " already mapped, cannot apply " + << nameOfMap + << flatOutput(mo) << abort(FatalError); + } + + // Map from masters, uniform weights + addr[facei] = mo; + wght[facei] = scalarList(mo.size(), 1.0/mo.size()); } + }; - // Map from masters, uniform weights - addr[facei] = mo; - w[facei] = scalarList(mo.size(), 1.0/mo.size()); - } - const List& ffe = mpm_.facesFromEdgesMap(); + setAddrWeights(mpm_.facesFromPointsMap(), "point faces"); + setAddrWeights(mpm_.facesFromEdgesMap(), "edge faces"); + setAddrWeights(mpm_.facesFromFacesMap(), "face faces"); + + + // Do mapped faces. + // - may already have been set, so check if addressing still empty(). - forAll(ffe, ffeI) { - // Get addressing - const labelList& mo = ffe[ffeI].masterObjects(); + const labelList& map = mpm_.faceMap(); - label facei = ffe[ffeI].index(); - - if (addr[facei].size()) + // NB: faceMap can be longer than nFaces() + for (label facei = 0; facei < mapperLen_; ++facei) { - FatalErrorInFunction - << "Master face " << facei - << " mapped from edge faces " << mo - << " already destination of mapping." << abort(FatalError); - } + const label mappedi = map[facei]; - // Map from masters, uniform weights - addr[facei] = mo; - w[facei] = scalarList(mo.size(), 1.0/mo.size()); - } - - const List& fff = mpm_.facesFromFacesMap(); - - forAll(fff, fffI) - { - // Get addressing - const labelList& mo = fff[fffI].masterObjects(); - - label facei = fff[fffI].index(); - - if (addr[facei].size()) - { - FatalErrorInFunction - << "Master face " << facei - << " mapped from face faces " << mo - << " already destination of mapping." << abort(FatalError); - } - - // Map from masters, uniform weights - addr[facei] = mo; - w[facei] = scalarList(mo.size(), 1.0/mo.size()); - } - - - // Do mapped faces. Note that can already be set from facesFromFaces - // so check if addressing size still zero. - const labelList& fm = mpm_.faceMap(); - - forAll(fm, facei) - { - if (fm[facei] > -1 && addr[facei].empty()) - { - // Mapped from a single face - addr[facei] = labelList(1, fm[facei]); - w[facei] = scalarList(1, 1.0); + if (mappedi >= 0 && addr[facei].empty()) + { + // Mapped from a single face + addr[facei].resize(1, mappedi); + wght[facei].resize(1, 1.0); + } } } // Grab inserted faces (for them the size of addressing is still zero) - insertedFaceLabelsPtr_ = new labelList(mesh_.nFaces()); - labelList& insertedFaces = *insertedFaceLabelsPtr_; + insertedObjectsPtr_ = std::make_unique(); + auto& inserted = *insertedObjectsPtr_; - label nInsertedFaces = 0; - - forAll(addr, facei) + // The nInsertedObjects_ already counted in the constructor + if (nInsertedObjects_) { - if (addr[facei].empty()) + inserted.resize(nInsertedObjects_); + + label nInserted = 0; + forAll(addr, i) { - // Mapped from a dummy face - addr[facei] = labelList(1, Zero); - w[facei] = scalarList(1, scalar(1)); + if (addr[i].empty()) + { + // Mapped from dummy face 0 + addr[i].resize(1, 0); + wght[i].resize(1, 1.0); - insertedFaces[nInsertedFaces] = facei; - nInsertedFaces++; + inserted[nInserted] = i; + ++nInserted; + + // TBD: check (nInsertedObjects_ < nInserted)? + #ifdef FULLDEBUG + if (nInsertedObjects_ < nInserted) + { + FatalErrorInFunction + << "Unexpected insert of more than " + << nInsertedObjects_ << " items\n" + << abort(FatalError); + } + #endif + } } + // TBD: check (nInserted < nInsertedObjects_)? + #ifdef FULLDEBUG + if (nInserted < nInsertedObjects_) + { + WarningInFunction + << "Found " << nInserted << " instead of " + << nInsertedObjects_ << " items to insert\n"; + } + #endif + // The resize should be unnecessary + inserted.resize(nInserted); } - - insertedFaces.setSize(nInsertedFaces); } } -void Foam::faceMapper::clearOut() -{ - deleteDemandDrivenData(directAddrPtr_); - deleteDemandDrivenData(interpolationAddrPtr_); - deleteDemandDrivenData(weightsPtr_); - deleteDemandDrivenData(insertedFaceLabelsPtr_); -} +// void Foam::faceMapper::clearOut() +// { +// directAddrPtr_.reset(nullptr); +// interpAddrPtr_.reset(nullptr); +// weightsPtr_.reset(nullptr); +// insertedObjectsPtr_.reset(nullptr); +// } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::faceMapper::faceMapper(const mapPolyMesh& mpm) : - mesh_(mpm.mesh()), mpm_(mpm), - insertedFaces_(true), - direct_(false), - directAddrPtr_(nullptr), - interpolationAddrPtr_(nullptr), - weightsPtr_(nullptr), - insertedFaceLabelsPtr_(nullptr) -{ - // Check for possibility of direct mapping - if + mapperLen_(mpm.mesh().nFaces()), + nInsertedObjects_(0), + direct_ ( - mpm_.facesFromPointsMap().empty() - && mpm_.facesFromEdgesMap().empty() - && mpm_.facesFromFacesMap().empty() + // Mapping without interpolation? + mpm.facesFromPointsMap().empty() + && mpm.facesFromEdgesMap().empty() + && mpm.facesFromFacesMap().empty() ) +{ + const auto& directMap = mpm_.faceMap(); + + if (!mapperLen_) { + // Empty mesh direct_ = true; + nInsertedObjects_ = 0; + } + else if (direct_) + { + // Number of inserted faces (-ve values) + nInsertedObjects_ = std::count_if + ( + directMap.cbegin(), + directMap.cbegin(mapperLen_), + [](label i) { return (i < 0); } + ); } else { - direct_ = false; - } + // Check if there are inserted faces with no owner + // (check all lists) - // Check for inserted faces - if (direct_ && (mpm_.faceMap().empty() || min(mpm_.faceMap()) > -1)) - { - insertedFaces_ = false; - } - else - { - // Need to check all 3 lists to see if there are inserted faces - // with no owner + bitSet unmapped(mapperLen_, true); - // Make a copy of the face map, add the entries for faces from points - // and faces from edges and check for left-overs - labelList fm(mesh_.nFaces(), -1); + unmapped.unset(directMap); // direct mapped - const List& ffp = mpm_.facesFromPointsMap(); - - forAll(ffp, ffpI) + for (const auto& map : mpm_.facesFromPointsMap()) { - fm[ffp[ffpI].index()] = 0; + if (!map.empty()) unmapped.unset(map.index()); } - const List& ffe = mpm_.facesFromEdgesMap(); - - forAll(ffe, ffeI) + for (const auto& map : mpm_.facesFromEdgesMap()) { - fm[ffe[ffeI].index()] = 0; + if (!map.empty()) unmapped.unset(map.index()); } - const List& fff = mpm_.facesFromFacesMap(); - - forAll(fff, fffI) + for (const auto& map : mpm_.facesFromFacesMap()) { - fm[fff[fffI].index()] = 0; + if (!map.empty()) unmapped.unset(map.index()); } - if (min(fm) < 0) - { - insertedFaces_ = true; - } + nInsertedObjects_ = label(unmapped.count()); } } @@ -275,16 +292,14 @@ Foam::faceMapper::faceMapper(const mapPolyMesh& mpm) // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::faceMapper::~faceMapper() -{ - clearOut(); -} +{} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::label Foam::faceMapper::size() const { - return mesh_.nFaces(); + return mapperLen_; } @@ -335,12 +350,12 @@ const Foam::labelListList& Foam::faceMapper::addressing() const << abort(FatalError); } - if (!interpolationAddrPtr_) + if (!interpAddrPtr_) { calcAddressing(); } - return *interpolationAddrPtr_; + return *interpAddrPtr_; } @@ -364,20 +379,18 @@ const Foam::scalarListList& Foam::faceMapper::weights() const const Foam::labelList& Foam::faceMapper::insertedObjectLabels() const { - if (!insertedFaceLabelsPtr_) + if (!insertedObjectsPtr_) { - if (!insertedObjects()) + if (!nInsertedObjects_) { - // There are no inserted faces - insertedFaceLabelsPtr_ = new labelList(0); - } - else - { - calcAddressing(); + // No inserted objects will be created + return labelList::null(); } + + calcAddressing(); } - return *insertedFaceLabelsPtr_; + return *insertedObjectsPtr_; } diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.H index b5f43bad23..a1b331835d 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2013 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,8 +37,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef faceMapper_H -#define faceMapper_H +#ifndef Foam_faceMapper_H +#define Foam_faceMapper_H #include "morphFieldMapper.H" #include "HashSet.H" @@ -47,8 +48,7 @@ SourceFiles namespace Foam { -// Forward declaration of classes -class polyMesh; +// Forward Declarations class mapPolyMesh; /*---------------------------------------------------------------------------*\ @@ -59,38 +59,45 @@ class faceMapper : public morphFieldMapper { - // Private data - - //- Reference to polyMesh - const polyMesh& mesh_; + // Private Data //- Reference to mapPolyMesh const mapPolyMesh& mpm_; - //- Are there any inserted (unmapped) faces - bool insertedFaces_; + //- The size of the mapper = polyMesh::nFaces() + const label mapperLen_; + + //- Number of inserted (unmapped) faces + label nInsertedObjects_; //- Is the mapping direct bool direct_; - // Demand-driven private data + // Demand-Driven Data //- Direct addressing (only one for of addressing is used) - mutable labelList* directAddrPtr_; + mutable std::unique_ptr directAddrPtr_; //- Interpolated addressing (only one for of addressing is used) - mutable labelListList* interpolationAddrPtr_; + mutable std::unique_ptr interpAddrPtr_; //- Interpolation weights - mutable scalarListList* weightsPtr_; + mutable std::unique_ptr weightsPtr_; //- Inserted faces - mutable labelList* insertedFaceLabelsPtr_; + mutable std::unique_ptr insertedObjectsPtr_; // Private Member Functions + //- Calculate addressing for mapping with inserted faces + void calcAddressing() const; + +public: + + // Generated Methods + //- No copy construct faceMapper(const faceMapper&) = delete; @@ -98,21 +105,10 @@ class faceMapper void operator=(const faceMapper&) = delete; - //- Calculate addressing for mapping with inserted faces - void calcAddressing() const; - - //- Clear out local storage - void clearOut(); - - -public: - - // Static data members - // Constructors //- Construct from mapPolyMesh - faceMapper(const mapPolyMesh& mpm); + explicit faceMapper(const mapPolyMesh& mpm); //- Destructor @@ -121,7 +117,7 @@ public: // Member Functions - //- Return size + //- The mapper size virtual label size() const; //- Return size of field before mapping @@ -165,7 +161,7 @@ public: //- Are there any inserted faces virtual bool insertedObjects() const { - return insertedFaces_; + return bool(nInsertedObjects_); } //- Return list of inserted faces diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.C index ee7694bb11..5baa1ac33f 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.C @@ -257,7 +257,7 @@ Foam::mapPolyMesh::mapPolyMesh oldCellVolumesPtr_ = oldCellVolumesPtr.clone(); } - if (oldPatchStarts_.size() > 0) + if (oldPatchStarts_.size()) { // Calculate old patch sizes for (label patchi = 0; patchi < oldPatchStarts_.size() - 1; patchi++) diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.H index a7b8f955a5..38bb76e580 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -153,6 +153,7 @@ SourceFiles namespace Foam { +// Forward Declarations class polyMesh; /*---------------------------------------------------------------------------*\ @@ -161,7 +162,7 @@ class polyMesh; class mapPolyMesh { - // Private data + // Private Data //- Reference to polyMesh const polyMesh& mesh_; @@ -273,7 +274,9 @@ class mapPolyMesh autoPtr oldCellVolumesPtr_; - // Private Member Functions +public: + + // Generated Methods //- No copy construct mapPolyMesh(const mapPolyMesh&) = delete; @@ -282,14 +285,13 @@ class mapPolyMesh void operator=(const mapPolyMesh&) = delete; -public: - // Constructors //- Construct from mesh mapPolyMesh(const polyMesh& mesh); - //- Construct from components. Copy (except for oldCellVolumes). + //- Copy construct from components, + //- except for oldCellVolumes which is move construct mapPolyMesh ( const polyMesh& mesh, @@ -356,18 +358,19 @@ public: const bool reuse ); + // Member Functions // Access //- Return polyMesh - const polyMesh& mesh() const + const polyMesh& mesh() const noexcept { return mesh_; } //- Number of old points - label nOldPoints() const + label nOldPoints() const noexcept { return nOldPoints_; } @@ -379,13 +382,13 @@ public: } //- Number of old faces - label nOldFaces() const + label nOldFaces() const noexcept { return nOldFaces_; } //- Number of old cells - label nOldCells() const + label nOldCells() const noexcept { return nOldCells_; } @@ -394,13 +397,13 @@ public: // Contains the old point label for all new points. // For preserved points this is the old point label. // For added points this is the master point ID - const labelList& pointMap() const + const labelList& pointMap() const noexcept { return pointMap_; } //- Points originating from points - const List& pointsFromPointsMap() const + const List& pointsFromPointsMap() const noexcept { return pointsFromPointsMap_; } @@ -408,56 +411,56 @@ public: //- Old face map. // Contains a list of old face labels for every new face. // Warning: this map contains invalid entries for new faces - const labelList& faceMap() const + const labelList& faceMap() const noexcept { return faceMap_; } //- Faces inflated from points - const List& facesFromPointsMap() const + const List& facesFromPointsMap() const noexcept { return facesFromPointsMap_; } //- Faces inflated from edges - const List& facesFromEdgesMap() const + const List& facesFromEdgesMap() const noexcept { return facesFromEdgesMap_; } //- Faces originating from faces - const List& facesFromFacesMap() const + const List& facesFromFacesMap() const noexcept { return facesFromFacesMap_; } //- Old cell map. // Contains old cell label for all preserved cells. - const labelList& cellMap() const + const labelList& cellMap() const noexcept { return cellMap_; } //- Cells inflated from points - const List& cellsFromPointsMap() const + const List& cellsFromPointsMap() const noexcept { return cellsFromPointsMap_; } //- Cells inflated from edges - const List& cellsFromEdgesMap() const + const List& cellsFromEdgesMap() const noexcept { return cellsFromEdgesMap_; } //- Cells inflated from faces - const List& cellsFromFacesMap() const + const List& cellsFromFacesMap() const noexcept { return cellsFromFacesMap_; } //- Cells originating from cells - const List& cellsFromCellsMap() const + const List& cellsFromCellsMap() const noexcept { return cellsFromCellsMap_; } @@ -467,7 +470,7 @@ public: //- Reverse point map // Contains new point label for all old and added points - const labelList& reversePointMap() const + const labelList& reversePointMap() const noexcept { return reversePointMap_; } @@ -499,7 +502,7 @@ public: //- Reverse face map // Contains new face label for all old and added faces - const labelList& reverseFaceMap() const + const labelList& reverseFaceMap() const noexcept { return reverseFaceMap_; } @@ -530,7 +533,7 @@ public: //- Reverse cell map // Contains new cell label for all old and added cells - const labelList& reverseCellMap() const + const labelList& reverseCellMap() const noexcept { return reverseCellMap_; } @@ -560,7 +563,7 @@ public: } //- Map of flipped face flux faces - const labelHashSet& flipFaceFlux() const + const labelHashSet& flipFaceFlux() const noexcept { return flipFaceFlux_; } @@ -568,7 +571,7 @@ public: //- Patch point renumbering // For every preserved point on a patch give the old position. // For added points, the index is set to -1 - const labelListList& patchPointMap() const + const labelListList& patchPointMap() const noexcept { return patchPointMap_; } @@ -579,7 +582,7 @@ public: //- Point zone renumbering // For every preserved point in zone give the old position. // For added points, the index is set to -1 - const labelListList& pointZoneMap() const + const labelListList& pointZoneMap() const noexcept { return pointZoneMap_; } @@ -587,7 +590,7 @@ public: //- Face zone point renumbering // For every preserved point in zone give the old position. // For added points, the index is set to -1 - const labelListList& faceZonePointMap() const + const labelListList& faceZonePointMap() const noexcept { return faceZonePointMap_; } @@ -595,7 +598,7 @@ public: //- Face zone face renumbering // For every preserved face in zone give the old position. // For added faces, the index is set to -1 - const labelListList& faceZoneFaceMap() const + const labelListList& faceZoneFaceMap() const noexcept { return faceZoneFaceMap_; } @@ -603,7 +606,7 @@ public: //- Cell zone renumbering // For every preserved cell in zone give the old position. // For added cells, the index is set to -1 - const labelListList& cellZoneMap() const + const labelListList& cellZoneMap() const noexcept { return cellZoneMap_; } @@ -611,49 +614,48 @@ public: //- Pre-motion point positions. // This specifies the correct way of blowing up // zero-volume objects - const pointField& preMotionPoints() const + const pointField& preMotionPoints() const noexcept { return preMotionPoints_; } //- Has valid preMotionPoints? - bool hasMotionPoints() const + bool hasMotionPoints() const noexcept { - return preMotionPoints_.size() > 0; + return !preMotionPoints_.empty(); } //- Return list of the old patch sizes - const labelList& oldPatchSizes() const + const labelList& oldPatchSizes() const noexcept { return oldPatchSizes_; } //- Return list of the old patch start labels - const labelList& oldPatchStarts() const + const labelList& oldPatchStarts() const noexcept { return oldPatchStarts_; } //- Return numbers of mesh points per old patch - const labelList& oldPatchNMeshPoints() const + const labelList& oldPatchNMeshPoints() const noexcept { return oldPatchNMeshPoints_; } - // Geometric mapping data + // Geometric mapping data - bool hasOldCellVolumes() const - { - return bool(oldCellVolumesPtr_); - } - - const scalarField& oldCellVolumes() const - { - return *oldCellVolumesPtr_; - } + bool hasOldCellVolumes() const noexcept + { + return bool(oldCellVolumesPtr_); + } + const scalarField& oldCellVolumes() const + { + return *oldCellVolumesPtr_; + } }; diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/objectMap/objectMap.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/objectMap/objectMap.H index 676ae13729..4b739eeafe 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/objectMap/objectMap.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/objectMap/objectMap.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation + Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,10 +36,10 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef objectMap_H -#define objectMap_H +#ifndef Foam_objectMap_H +#define Foam_objectMap_H -#include "labelList.H" +#include "List.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -46,7 +47,6 @@ namespace Foam { // Forward Declarations - class objectMap; inline bool operator==(const objectMap& a, const objectMap& b); inline bool operator!=(const objectMap& a, const objectMap& b); @@ -60,38 +60,51 @@ inline Istream& operator>>(Istream&, objectMap&); class objectMap { - // Private data + // Private Data //- Object index label index_; - //- Master object index - labelList masterObjects_; + //- Master object indices + labelList objects_; public: // Constructors - //- Null constructor, with index=-1 and no objects - inline objectMap(); + //- Default construct, with index=-1 and no objects + objectMap() noexcept : index_(-1) {} - //- Construct from components - inline objectMap(const label index, const UList