diff --git a/applications/utilities/miscellaneous/patchSummary/Make/options b/applications/utilities/miscellaneous/patchSummary/Make/options index 318e1be8f4..b49a4d1ad0 100644 --- a/applications/utilities/miscellaneous/patchSummary/Make/options +++ b/applications/utilities/miscellaneous/patchSummary/Make/options @@ -1,5 +1,6 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/genericPatchFields/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = \ diff --git a/applications/utilities/miscellaneous/patchSummary/patchSummaryTemplates.C b/applications/utilities/miscellaneous/patchSummary/patchSummaryTemplates.C index b456b77c1c..9435026c8b 100644 --- a/applications/utilities/miscellaneous/patchSummary/patchSummaryTemplates.C +++ b/applications/utilities/miscellaneous/patchSummary/patchSummaryTemplates.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-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,10 +24,25 @@ License \*---------------------------------------------------------------------------*/ #include "patchSummaryTemplates.H" +#include "genericPatchField.H" #include "IOmanip.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +template +Foam::word Foam::patchFieldType(const PatchField& pf) +{ + if (isA(pf)) + { + return refCast(pf).actualTypeName(); + } + else + { + return pf.type(); + } +} + + template void Foam::addToFieldList ( @@ -63,7 +78,8 @@ void Foam::outputFieldList Info<< " " << pTraits::typeName << tab << tab << fieldList[fieldi].name() << tab << tab - << fieldList[fieldi].boundaryField()[patchi].type() << nl; + << patchFieldType(fieldList[fieldi].boundaryField()[patchi]) + << nl; } } } @@ -84,7 +100,7 @@ void Foam::collectFieldList fieldToType.insert ( fieldList[fieldi].name(), - fieldList[fieldi].boundaryField()[patchi].type() + patchFieldType(fieldList[fieldi].boundaryField()[patchi]) ); } } diff --git a/applications/utilities/miscellaneous/patchSummary/patchSummaryTemplates.H b/applications/utilities/miscellaneous/patchSummary/patchSummaryTemplates.H index 795d850778..9a2000414a 100644 --- a/applications/utilities/miscellaneous/patchSummary/patchSummaryTemplates.H +++ b/applications/utilities/miscellaneous/patchSummary/patchSummaryTemplates.H @@ -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-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,6 +33,9 @@ License namespace Foam { + template + word patchFieldType(const PatchField& pf); + template void addToFieldList ( diff --git a/src/genericPatchFields/Make/files b/src/genericPatchFields/Make/files index 333d154a6d..bf28e03483 100644 --- a/src/genericPatchFields/Make/files +++ b/src/genericPatchFields/Make/files @@ -1,3 +1,4 @@ +genericPatchField/genericPatchField.C genericFvPatchField/genericFvPatchFields.C genericPointPatchField/genericPointPatchFields.C diff --git a/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C b/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C index 014c9704f3..10e2b1a9c3 100644 --- a/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C +++ b/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C @@ -53,8 +53,8 @@ Foam::genericFvPatchField::genericFvPatchField const dictionary& dict ) : + genericPatchField(dict.lookup("type")), calculatedFvPatchField(p, iF, dict), - actualTypeName_(dict.lookup("type")), dict_(dict) { if (!dict.found("value")) @@ -69,7 +69,7 @@ Foam::genericFvPatchField::genericFvPatchField << nl << " which is required to set the" " values of the generic patch field." << nl - << " (Actual type " << actualTypeName_ << ")" << nl + << " (Actual type " << actualTypeName() << ")" << nl << "\n Please add the 'value' entry to the write function " "of the user-defined boundary-condition\n" << exit(FatalIOError); @@ -420,8 +420,8 @@ Foam::genericFvPatchField::genericFvPatchField const fvPatchFieldMapper& mapper ) : + genericPatchField(ptf), calculatedFvPatchField(ptf, p, iF, mapper), - actualTypeName_(ptf.actualTypeName_), dict_(ptf.dict_) { forAllConstIter @@ -502,8 +502,8 @@ Foam::genericFvPatchField::genericFvPatchField const genericFvPatchField& ptf ) : + genericPatchField(ptf), calculatedFvPatchField(ptf), - actualTypeName_(ptf.actualTypeName_), dict_(ptf.dict_), scalarFields_(ptf.scalarFields_), vectorFields_(ptf.vectorFields_), @@ -520,8 +520,8 @@ Foam::genericFvPatchField::genericFvPatchField const DimensionedField& iF ) : + genericPatchField(ptf), calculatedFvPatchField(ptf, iF), - actualTypeName_(ptf.actualTypeName_), dict_(ptf.dict_), scalarFields_(ptf.scalarFields_), vectorFields_(ptf.vectorFields_), @@ -696,7 +696,7 @@ Foam::genericFvPatchField::valueInternalCoeffs { FatalErrorInFunction << "cannot be called for a genericFvPatchField" - " (actual type " << actualTypeName_ << ")" + " (actual type " << actualTypeName() << ")" << "\n on patch " << this->patch().name() << " of field " << this->internalField().name() << " in file " << this->internalField().objectPath() @@ -717,7 +717,7 @@ Foam::genericFvPatchField::valueBoundaryCoeffs { FatalErrorInFunction << "cannot be called for a genericFvPatchField" - " (actual type " << actualTypeName_ << ")" + " (actual type " << actualTypeName() << ")" << "\n on patch " << this->patch().name() << " of field " << this->internalField().name() << " in file " << this->internalField().objectPath() @@ -735,7 +735,7 @@ Foam::genericFvPatchField::gradientInternalCoeffs() const { FatalErrorInFunction << "cannot be called for a genericFvPatchField" - " (actual type " << actualTypeName_ << ")" + " (actual type " << actualTypeName() << ")" << "\n on patch " << this->patch().name() << " of field " << this->internalField().name() << " in file " << this->internalField().objectPath() @@ -752,7 +752,7 @@ Foam::genericFvPatchField::gradientBoundaryCoeffs() const { FatalErrorInFunction << "cannot be called for a genericFvPatchField" - " (actual type " << actualTypeName_ << ")" + " (actual type " << actualTypeName() << ")" << "\n on patch " << this->patch().name() << " of field " << this->internalField().name() << " in file " << this->internalField().objectPath() @@ -767,7 +767,7 @@ Foam::genericFvPatchField::gradientBoundaryCoeffs() const template void Foam::genericFvPatchField::write(Ostream& os) const { - writeEntry(os, "type", actualTypeName_); + writeEntry(os, "type", actualTypeName()); forAllConstIter(dictionary, dict_, iter) { diff --git a/src/genericPatchFields/genericFvPatchField/genericFvPatchField.H b/src/genericPatchFields/genericFvPatchField/genericFvPatchField.H index 8c1fef9d3d..13a7f3ca1e 100644 --- a/src/genericPatchFields/genericFvPatchField/genericFvPatchField.H +++ b/src/genericPatchFields/genericFvPatchField/genericFvPatchField.H @@ -40,6 +40,7 @@ SourceFiles #ifndef genericFvPatchField_H #define genericFvPatchField_H +#include "genericPatchField.H" #include "calculatedFvPatchField.H" #include "HashPtrTable.H" @@ -55,11 +56,11 @@ namespace Foam template class genericFvPatchField : + public genericPatchField, public calculatedFvPatchField { // Private Data - word actualTypeName_; dictionary dict_; HashPtrTable scalarFields_; diff --git a/src/genericPatchFields/genericPatchField/genericPatchField.C b/src/genericPatchFields/genericPatchField/genericPatchField.C new file mode 100644 index 0000000000..6a87b52585 --- /dev/null +++ b/src/genericPatchFields/genericPatchField/genericPatchField.C @@ -0,0 +1,35 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2019 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "genericPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(genericPatchField, 0); +} + +// ************************************************************************* // diff --git a/src/genericPatchFields/genericPatchField/genericPatchField.H b/src/genericPatchFields/genericPatchField/genericPatchField.H new file mode 100644 index 0000000000..fcc00d0371 --- /dev/null +++ b/src/genericPatchFields/genericPatchField/genericPatchField.H @@ -0,0 +1,94 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2019 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::genericPatchField + +Description + +SourceFiles + genericPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef genericPatchField_H +#define genericPatchField_H + +#include "typeInfo.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class genericFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class genericPatchField +{ + // Private Data + + word actualTypeName_; + +public: + + //- Runtime type information + TypeName("generic"); + + + // Constructors + + genericPatchField() + {} + + genericPatchField(const word& atn) + : + actualTypeName_(atn) + {} + + + //- Destructor + virtual ~genericPatchField() + {} + + + // Member Functions + + //- Return the actual type name + word actualTypeName() const + { + return actualTypeName_; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C b/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C index fb27ddd91a..e35b8fcc9a 100644 --- a/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C +++ b/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C @@ -49,8 +49,8 @@ Foam::genericPointPatchField::genericPointPatchField const dictionary& dict ) : + genericPatchField(dict.lookup("type")), calculatedPointPatchField(p, iF, dict), - actualTypeName_(dict.lookup("type")), dict_(dict) { forAllConstIter(dictionary, dict_, iter) @@ -311,8 +311,8 @@ Foam::genericPointPatchField::genericPointPatchField const pointPatchFieldMapper& mapper ) : + genericPatchField(ptf), calculatedPointPatchField(ptf, p, iF, mapper), - actualTypeName_(ptf.actualTypeName_), dict_(ptf.dict_) { forAllConstIter @@ -394,8 +394,8 @@ Foam::genericPointPatchField::genericPointPatchField const DimensionedField& iF ) : + genericPatchField(ptf), calculatedPointPatchField(ptf, iF), - actualTypeName_(ptf.actualTypeName_), dict_(ptf.dict_), scalarFields_(ptf.scalarFields_), vectorFields_(ptf.vectorFields_), @@ -560,7 +560,7 @@ void Foam::genericPointPatchField::rmap template void Foam::genericPointPatchField::write(Ostream& os) const { - writeEntry(os, "type", actualTypeName_); + writeEntry(os, "type", actualTypeName()); forAllConstIter(dictionary, dict_, iter) { diff --git a/src/genericPatchFields/genericPointPatchField/genericPointPatchField.H b/src/genericPatchFields/genericPointPatchField/genericPointPatchField.H index 627f24194c..b90a01ffb6 100644 --- a/src/genericPatchFields/genericPointPatchField/genericPointPatchField.H +++ b/src/genericPatchFields/genericPointPatchField/genericPointPatchField.H @@ -36,6 +36,7 @@ SourceFiles #ifndef genericPointPatchField_H #define genericPointPatchField_H +#include "genericPatchField.H" #include "calculatedPointPatchField.H" #include "HashPtrTable.H" @@ -51,11 +52,11 @@ namespace Foam template class genericPointPatchField : + public genericPatchField, public calculatedPointPatchField { // Private Data - word actualTypeName_; dictionary dict_; HashPtrTable scalarFields_;