diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C index 71324652b2..4be69297f8 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/value/valuePointPatchField.C @@ -69,7 +69,8 @@ Foam::valuePointPatchField::valuePointPatchField else { FatalIOErrorInFunction(dict) - << "Essential entry 'value' missing on patch " << p.name() + << "Essential entry 'value' missing on patch " + << p.name() << endl << exit(FatalIOError); } } diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C index cc4490fe85..1ec83dd17a 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C @@ -42,7 +42,7 @@ Foam::pointPatchField::pointPatchField patch_(p), internalField_(iF), updated_(false), - patchType_(word::null) + patchType_() {} @@ -57,8 +57,10 @@ Foam::pointPatchField::pointPatchField patch_(p), internalField_(iF), updated_(false), - patchType_(dict.getOrDefault("patchType", word::null)) -{} + patchType_() +{ + dict.readIfPresent("patchType", patchType_, keyType::LITERAL); +} template @@ -118,7 +120,7 @@ void Foam::pointPatchField::write(Ostream& os) const { os.writeEntry("type", type()); - if (patchType_.size()) + if (!patchType_.empty()) { os.writeEntry("patchType", patchType_); } diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H index 92aee089a6..b634662092 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H @@ -202,9 +202,9 @@ public: // (does not set the patch field values) static autoPtr> New ( - const word&, - const pointPatch&, - const DimensionedField& + const word& patchFieldType, + const pointPatch& p, + const DimensionedField& iF ); //- Return a pointer to a new patchField created on freestore given @@ -213,10 +213,10 @@ public: // Allows override of constraint type static autoPtr> New ( - const word&, + const word& patchFieldType, const word& actualPatchType, - const pointPatch&, - const DimensionedField& + const pointPatch& p, + const DimensionedField& iF ); //- Return a pointer to a new patchField created on freestore from diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C index 38efd74909..4c47084577 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,7 +37,10 @@ Foam::autoPtr> Foam::pointPatchField::New const DimensionedField& iF ) { - DebugInFunction << "Constructing pointPatchField" << endl; + DebugInFunction + << "patchFieldType = " << patchFieldType + << " [" << actualPatchType + << "] : " << p.type() << " name = " << p.name() << endl; auto* ctorPtr = pointPatchConstructorTable(patchFieldType); @@ -53,11 +56,7 @@ Foam::autoPtr> Foam::pointPatchField::New autoPtr> pfPtr(ctorPtr(p, iF)); - if - ( - actualPatchType.empty() - || actualPatchType != p.type() - ) + if (actualPatchType.empty() || actualPatchType != p.type()) { if (pfPtr().constraintType() != p.constraintType()) { @@ -110,10 +109,16 @@ Foam::autoPtr> Foam::pointPatchField::New const dictionary& dict ) { - DebugInFunction << "Constructing pointPatchField" << endl; - const word patchFieldType(dict.get("type")); + word actualPatchType; + dict.readIfPresent("patchType", actualPatchType, keyType::LITERAL); + + DebugInFunction + << "patchFieldType = " << patchFieldType + << " [" << actualPatchType + << "] : " << p.type() << " name = " << p.name() << endl; + auto* ctorPtr = dictionaryConstructorTable(patchFieldType); if (!ctorPtr) @@ -137,11 +142,7 @@ Foam::autoPtr> Foam::pointPatchField::New // Construct (but not necessarily returned) autoPtr> pfPtr(ctorPtr(p, iF, dict)); - if - ( - !dict.found("patchType") - || dict.get("patchType") != p.type() - ) + if (actualPatchType.empty() || actualPatchType != p.type()) { if (pfPtr().constraintType() != p.constraintType()) { @@ -176,7 +177,9 @@ Foam::autoPtr> Foam::pointPatchField::New const pointPatchFieldMapper& pfMapper ) { - DebugInFunction << "Constructing pointPatchField" << endl; + DebugInFunction + << "patchFieldType = " << ptf.type() + << " : " << p.type() << " name = " << p.name() << endl; auto* ctorPtr = patchMapperConstructorTable(ptf.type()); diff --git a/src/finiteArea/Make/files b/src/finiteArea/Make/files index 7c2cdd4123..99d971d4db 100644 --- a/src/finiteArea/Make/files +++ b/src/finiteArea/Make/files @@ -7,6 +7,7 @@ faMesh/faMeshTopology.C faMesh/faMeshUpdate.C faMesh/faMeshBoundaryHalo.C faMesh/faBoundaryMesh/faBoundaryMesh.C +faMesh/faBoundaryMesh/faBoundaryMeshEntries.C faPatches = faMesh/faPatches $(faPatches)/faPatch/faPatch.C diff --git a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMeshEntries.C b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMeshEntries.C new file mode 100644 index 0000000000..a2d9c3b021 --- /dev/null +++ b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMeshEntries.C @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 "faBoundaryMeshEntries.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeName(faBoundaryMeshEntries); +} + +// ************************************************************************* // diff --git a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMeshEntries.H b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMeshEntries.H new file mode 100644 index 0000000000..9059813c2b --- /dev/null +++ b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMeshEntries.H @@ -0,0 +1,104 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +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::faBoundaryMeshEntries + +Description + Read and store dictionary entries for finite-area boundary patches. + +SourceFiles + faBoundaryMeshEntries.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Foam_faBoundaryMeshEntries_H +#define Foam_faBoundaryMeshEntries_H + +#include "regIOobject.H" +#include "PtrList.H" +#include "entry.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class faBoundaryMeshEntries Declaration +\*---------------------------------------------------------------------------*/ + +class faBoundaryMeshEntries +: + public regIOobject, + public PtrList +{ +public: + + //- Runtime type information + TypeNameNoDebug("faBoundaryMesh"); + + + // Constructors + + //- Read construct from IOobject + explicit faBoundaryMeshEntries(const IOobject& io) + : + regIOobject(io), + PtrList() + { + if + ( + ( + io.readOpt() == IOobject::MUST_READ + || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED + ) + || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) + ) + { + readStream(typeName) >> *this; + } + } + + + // Member Functions + + bool writeData(Ostream&) const + { + NotImplemented; + return false; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteArea/faMesh/faMesh.C b/src/finiteArea/faMesh/faMesh.C index 1d58456666..32e767ee26 100644 --- a/src/finiteArea/faMesh/faMesh.C +++ b/src/finiteArea/faMesh/faMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -264,19 +264,46 @@ void Foam::faMesh::clearOut() const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::faMesh::faMesh(const polyMesh& pMesh, const zero) +bool Foam::faMesh::init(const bool doInit) +{ + if (doInit) + { + setPrimitiveMeshData(); + } + + // Create global mesh data + if (Pstream::parRun()) + { + (void)globalData(); + } + + // Calculate topology for the patches (processor-processor comms etc.) + boundary_.updateMesh(); + + // Calculate the geometry for the patches (transformation tensors etc.) + boundary_.calcGeometry(); + + return false; +} + + +Foam::faMesh::faMesh(const polyMesh& pMesh, const Foam::zero) : - faMesh(pMesh, labelList()) + faMesh(pMesh, labelList(), static_cast(pMesh)) {} -Foam::faMesh::faMesh(const polyMesh& pMesh) +Foam::faMesh::faMesh +( + const polyMesh& pMesh, + const bool doInit +) : MeshObject(pMesh), - edgeInterpolation(*this), faSchemes(mesh()), + edgeInterpolation(*this), faSolution(mesh()), - data(mesh()), + data(mesh()), // Always NO_READ, NO_WRITE faceLabels_ ( IOobject @@ -294,7 +321,14 @@ Foam::faMesh::faMesh(const polyMesh& pMesh) IOobject ( "faBoundary", - time().findInstance(meshDir(), "faBoundary"), + // Allow boundary file that is newer than faceLabels + time().findInstance + ( + meshDir(), + "faBoundary", + IOobject::MUST_READ, + faceLabels_.instance() + ), faMesh::meshSubDir, mesh(), IOobject::MUST_READ, @@ -331,19 +365,12 @@ Foam::faMesh::faMesh(const polyMesh& pMesh) setPrimitiveMeshData(); - // Create global mesh data - if (Pstream::parRun()) + if (doInit) { - globalData(); + faMesh::init(false); // do not init lower levels } - // Calculate topology for the patches (processor-processor comms etc.) - boundary_.updateMesh(); - - // Calculate the geometry for the patches (transformation tensors etc.) - boundary_.calcGeometry(); - - if (fileHandler().isFile(pMesh.time().timePath()/"S0")) + if (doInit && fileHandler().isFile(pMesh.time().timePath()/"S0")) { S0Ptr_ = new DimensionedField ( @@ -365,14 +392,25 @@ Foam::faMesh::faMesh(const polyMesh& pMesh) Foam::faMesh::faMesh ( const polyMesh& pMesh, - const UList