From 261d5ccd6d69ef1bf2e7f347dafa51fe123425d8 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Tue, 29 Jun 2021 14:20:54 +0100 Subject: [PATCH] patchFields: Fixes to patchType handling This change fixes failures that occur with the mapping of fields with patchType overrides. It fixes a crash that previously occurred when redistributing patch fields with patchType overrides. It also makes decomposition correctly maintain patchType overrides on cyclics when those cyclics are separated and become processorCyclics. These fixes have been achieved by removing the patchType override data from the fv and point patches. Whether or not the field overrides the underlying patchType constraint is now determined on the fly from the patch and field names and what is available on the field run-time selection table. --- .../pointPatchField/pointPatchField.C | 18 ++- .../pointPatchField/pointPatchField.H | 99 ++++++++-------- .../pointPatchField/pointPatchFieldNew.C | 9 +- .../fixedGradient/fixedGradientFvPatchField.C | 39 +++++-- .../fixedGradient/fixedGradientFvPatchField.H | 8 +- .../fixedFluxPressureFvPatchScalarField.C | 38 +----- .../uniformInletOutletFvPatchField.C | 2 - .../uniformTotalPressureFvPatchScalarField.C | 4 +- .../fvPatchFields/fvPatchField/fvPatchField.C | 19 ++- .../fvPatchFields/fvPatchField/fvPatchField.H | 38 +++--- .../fvPatchField/fvPatchFieldNew.C | 17 +-- .../volPointInterpolate.C | 7 +- .../cyclicAMIPointPatchField.H | 4 +- .../decompose/decompose/fvFieldDecomposer.C | 27 +++-- .../fvFieldDecomposerDecomposeFields.C | 109 +++++++++--------- 15 files changed, 208 insertions(+), 230 deletions(-) diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C index 5dc5706158..8d59f419a4 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,8 +38,7 @@ Foam::pointPatchField::pointPatchField : patch_(p), internalField_(iF), - updated_(false), - patchType_(word::null) + updated_(false) {} @@ -53,8 +52,7 @@ Foam::pointPatchField::pointPatchField : patch_(p), internalField_(iF), - updated_(false), - patchType_(dict.lookupOrDefault("patchType", word::null)) + updated_(false) {} @@ -69,8 +67,7 @@ Foam::pointPatchField::pointPatchField : patch_(p), internalField_(iF), - updated_(false), - patchType_(ptf.patchType_) + updated_(false) {} @@ -83,8 +80,7 @@ Foam::pointPatchField::pointPatchField : patch_(ptf.patch_), internalField_(iF), - updated_(false), - patchType_(ptf.patchType_) + updated_(false) {} @@ -102,9 +98,9 @@ void Foam::pointPatchField::write(Ostream& os) const { writeEntry(os, "type", type()); - if (patchType_.size()) + if (overridesConstraint()) { - writeEntry(os, "patchType", patchType_); + writeEntry(os, "patchType", patch().type()); } } diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H index e11be0745b..d09aad3e79 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -93,11 +93,6 @@ class pointPatchField // the construction of the matrix bool updated_; - //- Optional patch type, used to allow specified boundary conditions - // to be applied to constraint patches by providing the constraint - // patch type as 'patchType' - word patchType_; - public: @@ -265,10 +260,10 @@ public: // Member Functions - // Access + // Attributes - //- Return local objectRegistry - const objectRegistry& db() const; + //- Return the type of the calculated form of pointPatchField + static const word& calculatedType(); //- Return size label size() const @@ -276,37 +271,6 @@ public: return patch().size(); } - //- Return patch - const pointPatch& patch() const - { - return patch_; - } - - //- Return dimensioned internal field reference - const DimensionedField& - internalField() const - { - return internalField_; - } - - //- Return internal field reference - const Field& primitiveField() const - { - return internalField_; - } - - //- Optional patch type - const word& patchType() const - { - return patchType_; - } - - //- Optional patch type - word& patchType() - { - return patchType_; - } - //- Return true if this patch field fixes a value virtual bool fixesValue() const { @@ -319,6 +283,52 @@ public: return false; } + //- Return the constraint type this pointPatchField implements. + virtual const word& constraintType() const + { + return word::null; + } + + //- Return true if this overrides the underlying constraint type + bool overridesConstraint() const + { + if (constraintType() == patch_.constraintType()) + { + return false; + } + + typename pointPatchConstructorTable::iterator patchTypeCstrIter + = pointPatchConstructorTablePtr_->find(patch_.type()); + + return + patchTypeCstrIter + != pointPatchConstructorTablePtr_->end(); + } + + + // Access + + //- Return local objectRegistry + const objectRegistry& db() const; + + //- Return patch + const pointPatch& patch() const + { + return patch_; + } + + //- Return dimensioned internal field reference + const DimensionedField& internalField() const + { + return internalField_; + } + + //- Return internal field reference + const Field& primitiveField() const + { + return internalField_; + } + //- Return true if the boundary condition has already been updated bool updated() const { @@ -383,15 +393,6 @@ public: const Field& pF ) const; - //- Return the type of the calculated form of pointPatchField - static const word& calculatedType(); - - //- Return the constraint type this pointPatchField implements. - virtual const word& constraintType() const - { - return word::null; - } - // Mapping functions diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C index 1d4cac47ba..2058f44a78 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -78,13 +78,6 @@ Foam::autoPtr> Foam::pointPatchField::New return patchTypeCstrIter()(p, iF); } } - else - { - if (pointPatchConstructorTablePtr_->found(p.type())) - { - pfPtr().patchType() = actualPatchType; - } - } return pfPtr; } diff --git a/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.C index c9698ae0a4..50cc5c5f0e 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.C @@ -45,13 +45,27 @@ Foam::fixedGradientFvPatchField::fixedGradientFvPatchField ( const fvPatch& p, const DimensionedField& iF, - const dictionary& dict + const dictionary& dict, + const bool gradientRequired ) : fvPatchField(p, iF, dict, false), - gradient_("gradient", dict, p.size()) + gradient_(p.size()) { - evaluate(); + if (gradientRequired) + { + if (dict.found("gradient")) + { + gradient_ = Field("gradient", dict, p.size()); + evaluate(); + } + else + { + FatalIOErrorInFunction(dict) + << "Essential entry 'gradient' missing" + << exit(FatalIOError); + } + } } @@ -61,12 +75,23 @@ Foam::fixedGradientFvPatchField::fixedGradientFvPatchField const fixedGradientFvPatchField& ptf, const fvPatch& p, const DimensionedField& iF, - const fvPatchFieldMapper& mapper + const fvPatchFieldMapper& mapper, + const bool mappingRequired ) : - fvPatchField(ptf, p, iF, mapper), - gradient_(mapper(ptf.gradient_)) -{} + fvPatchField(ptf, p, iF, mapper, mappingRequired), + gradient_(p.size()) +{ + if (mappingRequired) + { + // For unmapped faces set to internal field value (zero-gradient) + if (mapper.hasUnmapped()) + { + gradient_ = Zero; + } + mapper(gradient_, ptf); + } +} template diff --git a/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.H index d7c3ac25ac..b74764361c 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -104,7 +104,8 @@ public: ( const fvPatch&, const DimensionedField&, - const dictionary& + const dictionary&, + const bool gradientRequired=true ); //- Construct by mapping the given fixedGradientFvPatchField @@ -114,7 +115,8 @@ public: const fixedGradientFvPatchField&, const fvPatch&, const DimensionedField&, - const fvPatchFieldMapper& + const fvPatchFieldMapper&, + const bool mappingRequired=true ); //- Disallow copy without setting internal field reference diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C index ce8564fb18..5219c96d4c 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C @@ -49,21 +49,18 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField const dictionary& dict ) : - fixedGradientFvPatchScalarField(p, iF), + fixedGradientFvPatchScalarField(p, iF, dict, false), curTimeIndex_(-1) { if (dict.found("value") && dict.found("gradient")) { - fvPatchField::operator= - ( - scalarField("value", dict, p.size()) - ); + fvPatchField::operator=(scalarField("value", dict, p.size())); gradient() = scalarField("gradient", dict, p.size()); } else { fvPatchField::operator=(patchInternalField()); - gradient() = 0.0; + gradient() = Zero; } } @@ -76,34 +73,9 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField const fvPatchFieldMapper& mapper ) : - fixedGradientFvPatchScalarField(p, iF), + fixedGradientFvPatchScalarField(ptf, p, iF, mapper), curTimeIndex_(-1) -{ - patchType() = ptf.patchType(); - - // Map gradient. Set unmapped values and overwrite with mapped ptf - gradient() = 0.0; - mapper(gradient(), ptf.gradient()); - - // Evaluate the value field from the gradient if the internal field is valid - // if (notNull(iF) && iF.size()) - // { - // scalarField::operator= - // ( - // // patchInternalField() + gradient()/patch().deltaCoeffs() - // // ***HGW Hack to avoid the construction of mesh.deltaCoeffs - // // which fails for AMI patches for some mapping operations - // patchInternalField() - // + gradient()*(patch().nf() & patch().delta()) - // ); - // } - // else - { - // Enforce mapping of values so we have a valid starting value. This - // constructor is used when reconstructing fields - mapper(*this, ptf); - } -} +{} Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C index 26fcb00e36..205930ebeb 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C @@ -88,8 +88,6 @@ Foam::uniformInletOutletFvPatchField::uniformInletOutletFvPatchField phiName_(ptf.phiName_), uniformInletValue_(ptf.uniformInletValue_, false) { - this->patchType() = ptf.patchType(); - // Evaluate refValue since not mapped this->refValue() = uniformInletValue_->value(this->db().time().timeOutputValue()); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C index 159bc4cd8f..80a7bb3ec3 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -96,8 +96,6 @@ uniformTotalPressureFvPatchScalarField gamma_(ptf.gamma_), p0_(ptf.p0_, false) { - patchType() = ptf.patchType(); - // Set the patch pressure to the current total pressure // This is not ideal but avoids problems with the creation of patch faces const scalar t = this->db().time().timeOutputValue(); diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C index edc0b806ed..59b331c069 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C @@ -42,8 +42,7 @@ Foam::fvPatchField::fvPatchField patch_(p), internalField_(iF), updated_(false), - manipulatedMatrix_(false), - patchType_(word::null) + manipulatedMatrix_(false) {} @@ -59,8 +58,7 @@ Foam::fvPatchField::fvPatchField patch_(p), internalField_(iF), updated_(false), - manipulatedMatrix_(false), - patchType_(word::null) + manipulatedMatrix_(false) {} @@ -77,8 +75,7 @@ Foam::fvPatchField::fvPatchField patch_(p), internalField_(iF), updated_(false), - manipulatedMatrix_(false), - patchType_(dict.lookupOrDefault("patchType", word::null)) + manipulatedMatrix_(false) { if (valueRequired) { @@ -115,8 +112,7 @@ Foam::fvPatchField::fvPatchField patch_(p), internalField_(iF), updated_(false), - manipulatedMatrix_(false), - patchType_(ptf.patchType_) + manipulatedMatrix_(false) { if (mappingRequired) { @@ -141,8 +137,7 @@ Foam::fvPatchField::fvPatchField patch_(ptf.patch_), internalField_(iF), updated_(false), - manipulatedMatrix_(false), - patchType_(ptf.patchType_) + manipulatedMatrix_(false) {} @@ -266,9 +261,9 @@ void Foam::fvPatchField::write(Ostream& os) const { writeEntry(os, "type", type()); - if (patchType_.size()) + if (overridesConstraint()) { - writeEntry(os, "patchType", patchType_); + writeEntry(os, "patchType", patch().type()); } } diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H index f3a0a3f3b3..6ad900693b 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -101,11 +101,6 @@ class fvPatchField // during the construction of the matrix bool manipulatedMatrix_; - //- Optional patch type, used to allow specified boundary conditions - // to be applied to constraint patches by providing the constraint - // patch type as 'patchType' - word patchType_; - public: @@ -317,6 +312,22 @@ public: return false; } + //- Return true if this overrides the underlying constraint type + bool overridesConstraint() const + { + if (type() == patch_.type()) + { + return false; + } + + typename patchConstructorTable::iterator patchTypeCstrIter + = patchConstructorTablePtr_->find(patch_.type()); + + return + patchTypeCstrIter + != patchConstructorTablePtr_->end(); + } + // Access @@ -330,8 +341,7 @@ public: } //- Return dimensioned internal field reference - const DimensionedField& - internalField() const + const DimensionedField& internalField() const { return internalField_; } @@ -342,18 +352,6 @@ public: return internalField_; } - //- Optional patch type - const word& patchType() const - { - return patchType_; - } - - //- Optional patch type - word& patchType() - { - return patchType_; - } - //- Return true if the boundary condition has already been updated bool updated() const { diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchFieldNew.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchFieldNew.C index 0c892db9b6..78a9140e80 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchFieldNew.C +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchFieldNew.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -55,15 +55,15 @@ Foam::tmp> Foam::fvPatchField::New << exit(FatalError); } - typename patchConstructorTable::iterator patchTypeCstrIter = - patchConstructorTablePtr_->find(p.type()); - if ( actualPatchType == word::null || actualPatchType != p.type() ) { + typename patchConstructorTable::iterator patchTypeCstrIter = + patchConstructorTablePtr_->find(p.type()); + if (patchTypeCstrIter != patchConstructorTablePtr_->end()) { return patchTypeCstrIter()(p, iF); @@ -75,14 +75,7 @@ Foam::tmp> Foam::fvPatchField::New } else { - tmp> tfvp = cstrIter()(p, iF); - - // Check if constraint type override and store patchType if so - if ((patchTypeCstrIter != patchConstructorTablePtr_->end())) - { - tfvp.ref().patchType() = actualPatchType; - } - return tfvp; + return cstrIter()(p, iF); } } diff --git a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C index de650db1df..69f6d5ad52 100644 --- a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C +++ b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -263,11 +263,10 @@ void Foam::volPointInterpolation::interpolateBoundaryField wordList patchTypes(pf.boundaryField().size(), word::null); forAll(pf.boundaryField(), patchi) { - const word patchType = pf.boundaryField()[patchi].patchType(); - if (patchType != word::null) + if (pf.boundaryField()[patchi].overridesConstraint()) { havePatchTypes = true; - patchTypes[patchi] = patchType; + patchTypes[patchi] = pf.boundaryField()[patchi].patch().type(); } } if (!havePatchTypes) diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H index 43f47bc692..7fb3b4e6be 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -165,7 +165,7 @@ public: //- Return the constraint type this pointPatchField implements virtual const word& constraintType() const { - return cyclicAMIPointPatch::typeName; + return type(); } diff --git a/src/parallel/decompose/decompose/fvFieldDecomposer.C b/src/parallel/decompose/decompose/fvFieldDecomposer.C index 97be86fed0..b522582cad 100644 --- a/src/parallel/decompose/decompose/fvFieldDecomposer.C +++ b/src/parallel/decompose/decompose/fvFieldDecomposer.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -146,22 +146,27 @@ Foam::fvFieldDecomposer::fvFieldDecomposer { forAll(boundaryAddressing_, patchi) { - if - ( - boundaryAddressing_[patchi] >= 0 - && !isA(procMesh.boundary()[patchi]) - ) + const fvPatch& procPatch = procMesh.boundary()[patchi]; + + label fromPatchi = boundaryAddressing_[patchi]; + if (fromPatchi < 0 && isA(procPatch)) + { + const label referPatchi = + refCast + (procPatch.patch()).referPatchID(); + fromPatchi = boundaryAddressing_[referPatchi]; + } + + if (fromPatchi >= 0) { patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer ( procMesh_.boundary()[patchi].patchSlice(faceAddressing_), - completeMesh_.boundaryMesh() - [ - boundaryAddressing_[patchi] - ].start() + completeMesh_.boundaryMesh()[fromPatchi].start() ); } - else + + if (boundaryAddressing_[patchi] < 0) { processorVolPatchFieldDecomposerPtrs_[patchi] = new processorVolPatchFieldDecomposer diff --git a/src/parallel/decompose/decompose/fvFieldDecomposerDecomposeFields.C b/src/parallel/decompose/decompose/fvFieldDecomposerDecomposeFields.C index 98ecfb120f..3250f1cf90 100644 --- a/src/parallel/decompose/decompose/fvFieldDecomposerDecomposeFields.C +++ b/src/parallel/decompose/decompose/fvFieldDecomposerDecomposeFields.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -124,14 +124,26 @@ Foam::fvFieldDecomposer::decomposeField { const fvPatch& procPatch = procMesh_.boundary()[patchi]; - if (patchFieldDecomposerPtrs_[patchi]) + label fromPatchi = boundaryAddressing_[patchi]; + if (fromPatchi < 0 && isA(procPatch)) + { + const label referPatchi = + refCast + (procPatch.patch()).referPatchID(); + if (field.boundaryField()[referPatchi].overridesConstraint()) + { + fromPatchi = boundaryAddressing_[referPatchi]; + } + } + + if (fromPatchi >= 0) { bf.set ( patchi, fvPatchField::New ( - field.boundaryField()[boundaryAddressing_[patchi]], + field.boundaryField()[fromPatchi], procPatch, resF(), *patchFieldDecomposerPtrs_[patchi] @@ -288,7 +300,7 @@ Foam::fvFieldDecomposer::decomposeField { const fvPatch& procPatch = procMesh_.boundary()[patchi]; - if (patchFieldDecomposerPtrs_[patchi]) + if (boundaryAddressing_[patchi] >= 0) { bf.set ( @@ -302,57 +314,48 @@ Foam::fvFieldDecomposer::decomposeField ) ); } + else if (isA(procPatch)) + { + // Do our own mapping. Avoids a lot of mapping complexity. + bf.set + ( + patchi, + new processorCyclicFvsPatchField + ( + procPatch, + resF(), + mapField + ( + allFaceField, + procPatch.patchSlice(faceAddressing_), + doFlip + ) + ) + ); + } + else if (isA(procPatch)) + { + // Do our own mapping. Avoids a lot of mapping complexity. + bf.set + ( + patchi, + new processorFvsPatchField + ( + procPatch, + resF(), + mapField + ( + allFaceField, + procPatch.patchSlice(faceAddressing_), + doFlip + ) + ) + ); + } else { - // Do our own mapping - avoids a lot of mapping complexity - - if (isA(procPatch)) - { - bf.set - ( - patchi, - new processorCyclicFvsPatchField - ( - procPatch, - resF(), - mapField - ( - allFaceField, - procPatch.patchSlice - ( - faceAddressing_ - ), - doFlip - ) - ) - ); - } - else if (isA(procPatch)) - { - bf.set - ( - patchi, - new processorFvsPatchField - ( - procPatch, - resF(), - mapField - ( - allFaceField, - procPatch.patchSlice - ( - faceAddressing_ - ), - doFlip - ) - ) - ); - } - else - { - FatalErrorInFunction - << "Unknown type." << abort(FatalError); - } + FatalErrorInFunction + << "Unknown type." << abort(FatalError); } }