diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C index 705505a716..7fa8d4b8bc 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C @@ -72,7 +72,8 @@ GeometricBoundaryField ( const BoundaryMesh& bmesh, const DimensionedField& field, - const wordList& patchFieldTypes + const wordList& patchFieldTypes, + const wordList& constraintTypes ) : FieldField(bmesh.size()), @@ -83,18 +84,22 @@ GeometricBoundaryField Info<< "GeometricField::" "GeometricBoundaryField::" "GeometricBoundaryField(const BoundaryMesh&, " - "const Field&, const wordList&)" + "const Field&, const wordList&, const wordList&)" << endl; } - if (patchFieldTypes.size() != this->size()) + if + ( + patchFieldTypes.size() != this->size() + || (constraintTypes.size() && (constraintTypes.size() != this->size())) + ) { FatalErrorIn ( "GeometricField::" "GeometricBoundaryField::" "GeometricBoundaryField(const BoundaryMesh&, " - "const Field&, const wordList&)" + "const Field&, const wordList&, const wordList&)" ) << "Incorrect number of patch type specifications given" << nl << " Number of patches in mesh = " << bmesh.size() << " number of patch type specifications = " @@ -102,18 +107,38 @@ GeometricBoundaryField << abort(FatalError); } - forAll(bmesh_, patchi) + if (constraintTypes.size()) { - set - ( - patchi, - PatchField::New + forAll(bmesh_, patchi) + { + set ( - patchFieldTypes[patchi], - bmesh_[patchi], - field - ) - ); + patchi, + PatchField::New + ( + patchFieldTypes[patchi], + constraintTypes[patchi], + bmesh_[patchi], + field + ) + ); + } + } + else + { + forAll(bmesh_, patchi) + { + set + ( + patchi, + PatchField::New + ( + patchFieldTypes[patchi], + bmesh_[patchi], + field + ) + ); + } } } diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index 8c17c3886b..b4960c341d 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -231,14 +231,15 @@ Foam::GeometricField::GeometricField const IOobject& io, const Mesh& mesh, const dimensionSet& ds, - const wordList& patchFieldTypes + const wordList& patchFieldTypes, + const wordList& actualPatchTypes ) : DimensionedField(io, mesh, ds), timeIndex_(this->time().timeIndex()), field0Ptr_(NULL), fieldPrevIterPtr_(NULL), - boundaryField_(mesh.boundary(), *this, patchFieldTypes) + boundaryField_(mesh.boundary(), *this, patchFieldTypes, actualPatchTypes) { if (debug) { @@ -287,14 +288,15 @@ Foam::GeometricField::GeometricField const IOobject& io, const Mesh& mesh, const dimensioned& dt, - const wordList& patchFieldTypes + const wordList& patchFieldTypes, + const wordList& actualPatchTypes ) : DimensionedField(io, mesh, dt), timeIndex_(this->time().timeIndex()), field0Ptr_(NULL), fieldPrevIterPtr_(NULL), - boundaryField_(mesh.boundary(), *this, patchFieldTypes) + boundaryField_(mesh.boundary(), *this, patchFieldTypes, actualPatchTypes) { if (debug) { @@ -653,14 +655,22 @@ Foam::GeometricField::GeometricField ( const IOobject& io, const GeometricField& gf, - const wordList& patchFieldTypes + const wordList& patchFieldTypes, + const wordList& actualPatchTypes + ) : DimensionedField(io, gf), timeIndex_(gf.timeIndex()), field0Ptr_(NULL), fieldPrevIterPtr_(NULL), - boundaryField_(this->mesh().boundary(), *this, patchFieldTypes) + boundaryField_ + ( + this->mesh().boundary(), + *this, + patchFieldTypes, + actualPatchTypes + ) { if (debug) { diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H index 7d529ab40f..fa8ec179e4 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H @@ -128,12 +128,14 @@ public: //- Construct from a BoundaryMesh, // reference to the internal field - // and a wordList of patch types + // and a wordList of patch types and optional the actual patch + // types (to override constraint patches) GeometricBoundaryField ( const BoundaryMesh&, const DimensionedInternalField&, - const wordList& + const wordList& wantedPatchTypes, + const wordList& actualPatchTypes = wordList() ); //- Construct from a BoundaryMesh, @@ -283,7 +285,8 @@ public: const IOobject&, const Mesh&, const dimensionSet&, - const wordList& patchFieldTypes + const wordList& wantedPatchTypes, + const wordList& actualPatchTypes = wordList() ); //- Constructor given IOobject, mesh, dimensioned and patch type. @@ -301,7 +304,8 @@ public: const IOobject&, const Mesh&, const dimensioned&, - const wordList& patchFieldTypes + const wordList& wantedPatchTypes, + const wordList& actualPatchTypes = wordList() ); //- Constructor from components @@ -387,7 +391,8 @@ public: ( const IOobject&, const GeometricField&, - const wordList& patchFieldTypes + const wordList& patchFieldTypes, + const wordList& actualPatchTypes = wordList() ); diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/newPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/newPointPatchField.C index b14fbeac8f..749511b2cf 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/newPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/newPointPatchField.C @@ -29,6 +29,7 @@ template Foam::autoPtr > Foam::pointPatchField::New ( const word& patchFieldType, + const word& actualPatchType, const pointPatch& p, const DimensionedField& iF ) @@ -36,7 +37,8 @@ Foam::autoPtr > Foam::pointPatchField::New if (debug) { Info<< "PointPatchField::" - "New(const word&, const pointPatch&, const Field&) : " + "New(const word&, const word&" + ", const pointPatch&, const Field&) : " "constructing pointPatchField" << endl; } @@ -49,7 +51,7 @@ Foam::autoPtr > Foam::pointPatchField::New FatalErrorIn ( "PointPatchField::New" - "(const word&, const pointPatch&, const Field&)" + "(const word&, const word&, const pointPatch&, const Field&)" ) << "Unknown patchFieldType type " << patchFieldType << endl << endl @@ -60,31 +62,48 @@ Foam::autoPtr > Foam::pointPatchField::New autoPtr > pfPtr(cstrIter()(p, iF)); - if (pfPtr().constraintType() == p.constraintType()) + if + ( + actualPatchType == word::null + || actualPatchType != p.type() + ) { - // Compatible (constraint-wise) with the patch type - return pfPtr; - } - else - { - // Use default constraint type - typename pointPatchConstructorTable::iterator patchTypeCstrIter = - pointPatchConstructorTablePtr_->find(p.type()); - - if (patchTypeCstrIter == pointPatchConstructorTablePtr_->end()) + if (pfPtr().constraintType() != p.constraintType()) { - FatalErrorIn - ( - "PointPatchField::New" - "(const word&, const pointPatch&, const Field&)" - ) << "inconsistent patch and patchField types for \n" - << " patch type " << p.type() - << " and patchField type " << patchFieldType - << exit(FatalError); - } + // Use default constraint type + typename pointPatchConstructorTable::iterator patchTypeCstrIter = + pointPatchConstructorTablePtr_->find(p.type()); - return patchTypeCstrIter()(p, iF); + if (patchTypeCstrIter == pointPatchConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "PointPatchField::New" + "(const word&, const word&" + ", const pointPatch&, const Field&)" + ) << "inconsistent patch and patchField types for \n" + << " patch type " << p.type() + << " and patchField type " << patchFieldType + << exit(FatalError); + } + + return patchTypeCstrIter()(p, iF); + } } + + return pfPtr; +} + + +template +Foam::autoPtr > Foam::pointPatchField::New +( + const word& patchFieldType, + const pointPatch& p, + const DimensionedField& iF +) +{ + return New(patchFieldType, word::null, p, iF); } diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H index 98604bb4bf..869c536365 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H @@ -35,7 +35,7 @@ Description SourceFiles pointPatchField.C - newpointPatchField.C + newPointPatchField.C \*---------------------------------------------------------------------------*/ @@ -199,6 +199,18 @@ public: const DimensionedField& ); + //- Return a pointer to a new patchField created on freestore given + // patch and internal field + // (does not set the patch field values). + // Allows override of constraint type + static autoPtr > New + ( + const word&, + const word& actualPatchType, + const pointPatch&, + const DimensionedField& + ); + //- Return a pointer to a new patchField created on freestore from // a given pointPatchField mapped onto a new patch static autoPtr > New diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H index 1a8720af06..b1df3530ee 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H @@ -226,6 +226,18 @@ public: const DimensionedField& ); + //- Return a pointer to a new patchField created on freestore given + // patch and internal field + // (does not set the patch field values). + // Allows override of constraint type + static tmp > New + ( + const word&, + const word& actualPatchType, + const fvPatch&, + const DimensionedField& + ); + //- Return a pointer to a new patchField created on freestore from // a given fvPatchField mapped onto a new patch static tmp > New diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/newFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/newFvPatchField.C index 8f89f202d9..86884666a9 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/newFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/newFvPatchField.C @@ -29,14 +29,16 @@ template Foam::tmp > Foam::fvPatchField::New ( const word& patchFieldType, + const word& actualPatchType, const fvPatch& p, const DimensionedField& iF ) { if (debug) { - Info<< "fvPatchField::New(const word&, const fvPatch&, " - "const DimensionedField&) : patchFieldType=" + Info<< "fvPatchField::New(const word&, const word&, " + "const fvPatch&, const DimensionedField&) :" + " patchFieldType=" << patchFieldType << endl; } @@ -48,7 +50,7 @@ Foam::tmp > Foam::fvPatchField::New { FatalErrorIn ( - "fvPatchField::New(const word&, const fvPatch&, " + "fvPatchField::New(const word&, const word&, const fvPatch&, " "const DimensionedField&)" ) << "Unknown patchTypefield type " << patchFieldType << endl << endl @@ -57,12 +59,23 @@ Foam::tmp > Foam::fvPatchField::New << exit(FatalError); } - typename patchConstructorTable::iterator patchTypeCstrIter = - patchConstructorTablePtr_->find(p.type()); - - if (patchTypeCstrIter != patchConstructorTablePtr_->end()) + if + ( + actualPatchType == word::null + || actualPatchType != p.type() + ) { - return patchTypeCstrIter()(p, iF); + typename patchConstructorTable::iterator patchTypeCstrIter = + patchConstructorTablePtr_->find(p.type()); + + if (patchTypeCstrIter != patchConstructorTablePtr_->end()) + { + return patchTypeCstrIter()(p, iF); + } + else + { + return cstrIter()(p, iF); + } } else { @@ -71,6 +84,18 @@ Foam::tmp > Foam::fvPatchField::New } +template +Foam::tmp > Foam::fvPatchField::New +( + const word& patchFieldType, + const fvPatch& p, + const DimensionedField& iF +) +{ + return New(patchFieldType, word::null, p, iF); +} + + template Foam::tmp > Foam::fvPatchField::New ( diff --git a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H index b98fdcd453..c400d78d20 100644 --- a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H @@ -216,6 +216,18 @@ public: const DimensionedField& ); + //- Return a pointer to a new patchField created on freestore given + // patch and internal field + // (does not set the patch field values) + // Allows override of constraint type + static tmp > New + ( + const word&, + const word& actualPatchType, + const fvPatch&, + const DimensionedField& + ); + //- Return a pointer to a new patchField created on freestore from // a given fvsPatchField mapped onto a new patch static tmp > New diff --git a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/newFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/newFvsPatchField.C index b33ee35043..b8ad302fdd 100644 --- a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/newFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/newFvsPatchField.C @@ -34,14 +34,15 @@ template tmp > fvsPatchField::New ( const word& patchFieldType, + const word& actualPatchType, const fvPatch& p, const DimensionedField& iF ) { if (debug) { - Info<< "fvsPatchField::New(const word&, const fvPatch&, " - "const Field&) : " + Info<< "fvsPatchField::New(const word&, const word&" + ", const fvPatch&, const Field&) : " "constructing fvsPatchField" << endl; } @@ -53,8 +54,8 @@ tmp > fvsPatchField::New { FatalErrorIn ( - "fvsPatchField::New(const word&, const fvPatch&, " - "const Field&)" + "fvsPatchField::New(const word&, const word&, const fvPatch&" + ", const Field&)" ) << "Unknown patchTypefield type " << patchFieldType << endl << endl << "Valid patchField types are :" << endl @@ -62,12 +63,23 @@ tmp > fvsPatchField::New << exit(FatalError); } - typename patchConstructorTable::iterator patchTypeCstrIter = - patchConstructorTablePtr_->find(p.type()); - - if (patchTypeCstrIter != patchConstructorTablePtr_->end()) + if + ( + actualPatchType == word::null + || actualPatchType != p.type() + ) { - return patchTypeCstrIter()(p, iF); + typename patchConstructorTable::iterator patchTypeCstrIter = + patchConstructorTablePtr_->find(p.type()); + + if (patchTypeCstrIter != patchConstructorTablePtr_->end()) + { + return patchTypeCstrIter()(p, iF); + } + else + { + return cstrIter()(p, iF); + } } else { @@ -76,6 +88,18 @@ tmp > fvsPatchField::New } +template +tmp > fvsPatchField::New +( + const word& patchFieldType, + const fvPatch& p, + const DimensionedField& iF +) +{ + return New(patchFieldType, word::null, p, iF); +} + + template tmp > fvsPatchField::New ( diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C index 9d65cefc57..97cd9393bd 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C @@ -80,10 +80,11 @@ void Foam::fieldValues::cellSource::setCellZoneCells() } cellId_.setSize(count); + nCells_ = returnReduce(cellId_.size(), sumOp