diff --git a/src/OpenFOAM/fields/Fields/Field/Field.H b/src/OpenFOAM/fields/Fields/Field/Field.H index c7ad8907e1dfad91a55f2ef12e57ea3908140e0f..482efa7899e9267a98184e0cb8cc9a90c0ab2411 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.H +++ b/src/OpenFOAM/fields/Fields/Field/Field.H @@ -199,7 +199,7 @@ public: ); //- Construct by mapping from the given tmp field. Supplied uniform - // value for unmapped items + //- value for unmapped items Field ( const tmp<Field<Type>>& tmapF, @@ -209,7 +209,7 @@ public: ); //- Construct by mapping from the given tmp field. Supplied values - // for unmapped items + //- for unmapped items Field ( const tmp<Field<Type>>& tmapF, @@ -233,6 +233,12 @@ public: //- Clone inline tmp<Field<Type>> clone() const; + //- Return a pointer to a new Field created on freestore + static autoPtr<Field<Type>> New(Istream& is) + { + return autoPtr<Field<Type>>(new Field<Type>(is)); + } + //- Return a pointer to a new calculatedFvPatchFieldField created on // freestore without setting patchField values template<class Type2> diff --git a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.C b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.C index 436845ca36777ae5d315887d7c3bf7583a6474d3..e3aec27f3b199a7497113d19dfe429cb3cd507b0 100644 --- a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.C +++ b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.C @@ -40,7 +40,8 @@ Foam::faPatchField<Type>::faPatchField Field<Type>(p.size()), patch_(p), internalField_(iF), - updated_(false) + updated_(false), + patchType_(word::null) {} @@ -55,7 +56,8 @@ Foam::faPatchField<Type>::faPatchField Field<Type>(f), patch_(p), internalField_(iF), - updated_(false) + updated_(false), + patchType_(word::null) {} @@ -71,7 +73,8 @@ Foam::faPatchField<Type>::faPatchField Field<Type>(ptf, mapper), patch_(p), internalField_(iF), - updated_(false) + updated_(false), + patchType_(word::null) {} @@ -86,7 +89,8 @@ Foam::faPatchField<Type>::faPatchField Field<Type>(p.size()), patch_(p), internalField_(iF), - updated_(false) + updated_(false), + patchType_(dict.lookupOrDefault<word>("patchType", word::null)) { if (dict.found("value")) { @@ -111,7 +115,8 @@ Foam::faPatchField<Type>::faPatchField Field<Type>(ptf), patch_(ptf.patch_), internalField_(ptf.internalField_), - updated_(false) + updated_(false), + patchType_(ptf.patchType_) {} @@ -125,7 +130,8 @@ Foam::faPatchField<Type>::faPatchField Field<Type>(ptf), patch_(ptf.patch_), internalField_(iF), - updated_(false) + updated_(false), + patchType_(ptf.patchType_) {} @@ -200,6 +206,11 @@ template<class Type> void Foam::faPatchField<Type>::write(Ostream& os) const { os.writeEntry("type", type()); + + if (patchType_.size()) + { + os.writeEntry("patchType", patchType_); + } } diff --git a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H index 62ff60dc471049e380ff44cbd8be361d4f51c607..eca163cdc40038d1678313a2d5902b0223f11992 100644 --- a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H +++ b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H @@ -94,6 +94,11 @@ class faPatchField // 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: @@ -217,7 +222,18 @@ public: // (does not set the patch field values) static tmp<faPatchField<Type>> New ( - const word&, + const word& patchFieldType, + const word& actualPatchType, + const faPatch&, + const DimensionedField<Type, areaMesh>& + ); + + //- Return a pointer to a new patchField created on freestore given + // patch and internal field + // (does not set the patch field values) + static tmp<faPatchField<Type>> New + ( + const word& patchFieldType, const faPatch&, const DimensionedField<Type, areaMesh>& ); @@ -280,6 +296,18 @@ public: return internalField_; } + //- Optional patch type + const word& patchType() const + { + return patchType_; + } + + //- Optional patch type + word& patchType() + { + return patchType_; + } + //- Return the type of the calculated for of faPatchField static const word& calculatedType(); diff --git a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchFieldNew.C b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchFieldNew.C index 5189bb807370a4978303251de369d53148de1105..7c73e7d2355bf4cba0c81fe2d9cf3ef314b0502d 100644 --- a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchFieldNew.C +++ b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchFieldNew.C @@ -31,6 +31,7 @@ template<class Type> Foam::tmp<Foam::faPatchField<Type>> Foam::faPatchField<Type>::New ( const word& patchFieldType, + const word& actualPatchType, const faPatch& p, const DimensionedField<Type, areaMesh>& iF ) @@ -52,17 +53,47 @@ Foam::tmp<Foam::faPatchField<Type>> Foam::faPatchField<Type>::New auto patchTypeCstrIter = patchConstructorTablePtr_->cfind(p.type()); - if (patchTypeCstrIter.found()) + if + ( + actualPatchType == word::null + || actualPatchType != p.type() + ) { - return patchTypeCstrIter()(p, iF); + if (patchTypeCstrIter.found()) + { + return patchTypeCstrIter()(p, iF); + } + else + { + return cstrIter()(p, iF); + } } else { - return cstrIter()(p, iF); + tmp<faPatchField<Type>> tfap = cstrIter()(p, iF); + + // Check if constraint type override and store patchType if so + if (patchTypeCstrIter.found()) + { + tfap.ref().patchType() = actualPatchType; + } + return tfap; } } +template<class Type> +Foam::tmp<Foam::faPatchField<Type>> Foam::faPatchField<Type>::New +( + const word& patchFieldType, + const faPatch& p, + const DimensionedField<Type, areaMesh>& iF +) +{ + return New(patchFieldType, word::null, p, iF); +} + + template<class Type> Foam::tmp<Foam::faPatchField<Type>> Foam::faPatchField<Type>::New (