ENH: additional controls for faMesh construction (#2436)

- move construct from components. Construct with optional IO control

- separate init() method (as per polyMesh) to delay evaluation of
  globalData and base geometry.

- faMesh removeFiles method

ENH: faBoundaryMeshEntries for reading faBoundary files without a mesh

ENH: adjust debug output for {fa,fae,fv,fvs}patchField::New

- add alternative constraint type selection for faePatchField.

- unify handling of "patchType" reading.
  Make less noisy when reporting dictionary defaults.
This commit is contained in:
Mark Olesen
2022-04-02 18:03:46 +02:00
parent 60b31fc8e2
commit 7bdd355ef7
24 changed files with 496 additions and 215 deletions

View File

@ -69,7 +69,8 @@ Foam::valuePointPatchField<Type>::valuePointPatchField
else
{
FatalIOErrorInFunction(dict)
<< "Essential entry 'value' missing on patch " << p.name()
<< "Essential entry 'value' missing on patch "
<< p.name() << endl
<< exit(FatalIOError);
}
}

View File

@ -42,7 +42,7 @@ Foam::pointPatchField<Type>::pointPatchField
patch_(p),
internalField_(iF),
updated_(false),
patchType_(word::null)
patchType_()
{}
@ -57,8 +57,10 @@ Foam::pointPatchField<Type>::pointPatchField
patch_(p),
internalField_(iF),
updated_(false),
patchType_(dict.getOrDefault<word>("patchType", word::null))
{}
patchType_()
{
dict.readIfPresent("patchType", patchType_, keyType::LITERAL);
}
template<class Type>
@ -118,7 +120,7 @@ void Foam::pointPatchField<Type>::write(Ostream& os) const
{
os.writeEntry("type", type());
if (patchType_.size())
if (!patchType_.empty())
{
os.writeEntry("patchType", patchType_);
}

View File

@ -202,9 +202,9 @@ public:
// (does not set the patch field values)
static autoPtr<pointPatchField<Type>> New
(
const word&,
const pointPatch&,
const DimensionedField<Type, pointMesh>&
const word& patchFieldType,
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF
);
//- Return a pointer to a new patchField created on freestore given
@ -213,10 +213,10 @@ public:
// Allows override of constraint type
static autoPtr<pointPatchField<Type>> New
(
const word&,
const word& patchFieldType,
const word& actualPatchType,
const pointPatch&,
const DimensionedField<Type, pointMesh>&
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF
);
//- Return a pointer to a new patchField created on freestore from

View File

@ -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<Type>> Foam::pointPatchField<Type>::New
const DimensionedField<Type, pointMesh>& iF
)
{
DebugInFunction << "Constructing pointPatchField<Type>" << endl;
DebugInFunction
<< "patchFieldType = " << patchFieldType
<< " [" << actualPatchType
<< "] : " << p.type() << " name = " << p.name() << endl;
auto* ctorPtr = pointPatchConstructorTable(patchFieldType);
@ -53,11 +56,7 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
autoPtr<pointPatchField<Type>> 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<Type>> Foam::pointPatchField<Type>::New
const dictionary& dict
)
{
DebugInFunction << "Constructing pointPatchField<Type>" << endl;
const word patchFieldType(dict.get<word>("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<Type>> Foam::pointPatchField<Type>::New
// Construct (but not necessarily returned)
autoPtr<pointPatchField<Type>> pfPtr(ctorPtr(p, iF, dict));
if
(
!dict.found("patchType")
|| dict.get<word>("patchType") != p.type()
)
if (actualPatchType.empty() || actualPatchType != p.type())
{
if (pfPtr().constraintType() != p.constraintType())
{
@ -176,7 +177,9 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
const pointPatchFieldMapper& pfMapper
)
{
DebugInFunction << "Constructing pointPatchField<Type>" << endl;
DebugInFunction
<< "patchFieldType = " << ptf.type()
<< " : " << p.type() << " name = " << p.name() << endl;
auto* ctorPtr = patchMapperConstructorTable(ptf.type());

View File

@ -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

View File

@ -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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "faBoundaryMeshEntries.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeName(faBoundaryMeshEntries);
}
// ************************************************************************* //

View File

@ -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 <http://www.gnu.org/licenses/>.
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<entry>
{
public:
//- Runtime type information
TypeNameNoDebug("faBoundaryMesh");
// Constructors
//- Read construct from IOobject
explicit faBoundaryMeshEntries(const IOobject& io)
:
regIOobject(io),
PtrList<entry>()
{
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
// ************************************************************************* //

View File

@ -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<const IOobject&>(pMesh))
{}
Foam::faMesh::faMesh(const polyMesh& pMesh)
Foam::faMesh::faMesh
(
const polyMesh& pMesh,
const bool doInit
)
:
MeshObject<polyMesh, Foam::UpdateableMeshObject, faMesh>(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<scalar, areaMesh>
(
@ -365,14 +392,25 @@ Foam::faMesh::faMesh(const polyMesh& pMesh)
Foam::faMesh::faMesh
(
const polyMesh& pMesh,
const UList<label>& faceLabels
labelList&& faceLabels
)
:
faMesh(pMesh, std::move(faceLabels), static_cast<const IOobject&>(pMesh))
{}
Foam::faMesh::faMesh
(
const polyMesh& pMesh,
labelList&& faceLabels,
const IOobject& io
)
:
MeshObject<polyMesh, Foam::UpdateableMeshObject, faMesh>(pMesh),
faSchemes(mesh(), io.readOpt()),
edgeInterpolation(*this),
faSchemes(mesh()),
faSolution(mesh()),
data(mesh()),
faSolution(mesh(), io.readOpt()),
data(mesh()), // Always NO_READ, NO_WRITE
faceLabels_
(
IOobject
@ -384,7 +422,7 @@ Foam::faMesh::faMesh
IOobject::NO_READ,
IOobject::NO_WRITE
),
faceLabels
std::move(faceLabels)
),
boundary_
(
@ -427,7 +465,7 @@ Foam::faMesh::faMesh
{}
Foam::faMesh::faMesh(const polyPatch& pp)
Foam::faMesh::faMesh(const polyPatch& pp, const bool doInit)
:
faMesh
(
@ -447,24 +485,18 @@ Foam::faMesh::faMesh(const polyPatch& pp)
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();
}
Foam::faMesh::faMesh
(
const polyMesh& pMesh,
const dictionary& faMeshDefinition
const dictionary& faMeshDefinition,
const bool doInit
)
:
faMesh
@ -493,22 +525,14 @@ Foam::faMesh::faMesh
)
);
addFaPatches(newPatches);
// 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<scalar, areaMesh>
(
@ -573,6 +597,21 @@ const Foam::objectRegistry& Foam::faMesh::thisDb() const
}
void Foam::faMesh::removeFiles(const fileName& instanceDir) const
{
fileName meshFilesPath = thisDb().time().path()/instanceDir/meshDir();
Foam::rm(meshFilesPath/"faceLabels");
Foam::rm(meshFilesPath/"faBoundary");
}
void Foam::faMesh::removeFiles() const
{
removeFiles(mesh().instance());
}
const Foam::labelList& Foam::faMesh::patchStarts() const
{
if (!patchStartsPtr_)
@ -814,11 +853,10 @@ bool Foam::faMesh::movePoints()
}
// Move boundary points
const_cast<faBoundaryMesh&>(boundary_).movePoints(newPoints);
boundary_.movePoints(newPoints);
// Move interpolation
const edgeInterpolation& cei = *this;
const_cast<edgeInterpolation&>(cei).edgeInterpolation::movePoints();
edgeInterpolation::movePoints();
// Note: Fluxes were dummy?

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,7 +28,17 @@ Class
Foam::faMesh
Description
Finite area mesh. Used for 2-D non-Euclidian finite area method.
Finite area mesh (used for 2-D non-Euclidian finite area method)
defined using a \em patch of faces on a polyMesh
(ie, uindirectPrimitivePatch).
The ordering of faces and points on the faMesh corresponds to
the localFaces and localPoints as per Foam::PrimitivePatch but
the edge addressing is handled slightly differently.
The internal edges of the faMesh will generally correspond identically
to the internalEdges of the PrimitivePatch (may change in the future)
but the boundaryEdges will be reordered compared to the PrimitivePatch
to allow edge boundary slices to be obtained.
SourceFiles
faMesh.C
@ -84,8 +94,8 @@ class faMesh
:
public MeshObject<polyMesh, Foam::UpdateableMeshObject, faMesh>,
public lduMesh,
public edgeInterpolation,
public faSchemes,
public edgeInterpolation, // may need input from faSchemes
public faSolution,
public data
{
@ -213,10 +223,10 @@ class faMesh
// Primitive size data
//- Number of points
//- Total number of points
mutable label nPoints_;
//- Number of edges
//- Total number of edges
mutable label nEdges_;
//- Number of internal edges
@ -324,10 +334,12 @@ class faMesh
//- No copy assignment
void operator=(const faMesh&) = delete;
//- Set indirect patch, removing any old one
//- Set indirect patch, removing any old one.
// No communication
void initPatch() const;
//- Set primitive mesh data
//- Set primitive mesh data.
// No communication
void setPrimitiveMeshData();
//- Get list of (proc/patchi/patchEdgei/meshFacei) tuple pairs in an
@ -489,29 +501,38 @@ public:
// Constructors
//- Read construct from polyMesh, using its IOobject properties
explicit faMesh(const polyMesh& pMesh, const bool doInit = true);
//- Construct zero-sized from polyMesh
// Boundary is added using addFaPatches() member function
faMesh(const polyMesh& pMesh, const Foam::zero);
//- Construct from polyMesh
explicit faMesh(const polyMesh& pMesh);
//- Construct from components (face labels) without boundary,
//- using IOobject properties from polyMesh.
// Boundary is added using addFaPatches() member function.
faMesh(const polyMesh& pMesh, labelList&& faceLabels);
//- Construct for specified face labels without boundary.
// Boundary is added using addFaPatches() member function
//- Construct from components (face labels) without boundary,
//- using alternative IOobject properties
//- (primarily the readOption).
// Boundary is added using addFaPatches() member function.
faMesh
(
const polyMesh& pMesh,
const UList<label>& faceLabels
labelList&& faceLabels,
const IOobject& io
);
//- Construct from single polyPatch
explicit faMesh(const polyPatch& pp);
explicit faMesh(const polyPatch& pp, const bool doInit = true);
//- Construct from definition
faMesh
(
const polyMesh& pMesh,
const dictionary& faMeshDefinition
const dictionary& faMeshDefinition,
const bool doInit = true
);
@ -527,7 +548,7 @@ public:
// Member Functions
// Helpers
// Topological Change
//- Add boundary patches. Constructor helper
void addFaPatches
@ -543,6 +564,9 @@ public:
const bool validBoundary = true
);
//- Initialise non-demand-driven data etc
bool init(const bool doInit);
// Database
@ -694,19 +718,28 @@ public:
tmp<vectorField> haloFaceNormals(const label patchi) const;
// Mesh motion and morphing
// Storage management
//- Is mesh moving
bool moving() const
{
return mesh().moving();
}
//- Remove all files from mesh instance
void removeFiles(const fileName& instanceDir) const;
//- Update after mesh motion
virtual bool movePoints();
//- Remove all files from mesh instance()
void removeFiles() const;
//- Update after topo change
virtual void updateMesh(const mapPolyMesh&);
// Mesh motion and morphing
//- Is mesh moving
bool moving() const
{
return mesh().moving();
}
//- Update after mesh motion
virtual bool movePoints();
//- Update after topo change
virtual void updateMesh(const mapPolyMesh&);
// Mapping

View File

@ -42,7 +42,7 @@ Foam::faPatchField<Type>::faPatchField
patch_(p),
internalField_(iF),
updated_(false),
patchType_(word::null)
patchType_()
{}
@ -58,7 +58,7 @@ Foam::faPatchField<Type>::faPatchField
patch_(p),
internalField_(iF),
updated_(false),
patchType_(word::null)
patchType_()
{}
@ -75,7 +75,7 @@ Foam::faPatchField<Type>::faPatchField
patch_(p),
internalField_(iF),
updated_(false),
patchType_(word::null)
patchType_()
{}
@ -84,15 +84,20 @@ Foam::faPatchField<Type>::faPatchField
(
const faPatch& p,
const DimensionedField<Type, areaMesh>& iF,
const dictionary& dict
const dictionary& dict,
const bool valueRequired
)
:
Field<Type>(p.size()),
patch_(p),
internalField_(iF),
updated_(false),
patchType_(dict.getOrDefault<word>("patchType", word::null))
patchType_()
{
dict.readIfPresent("patchType", patchType_, keyType::LITERAL);
/// if (valueRequired) - not yet needed. Already a lazy evaluation
if (dict.found("value"))
{
faPatchField<Type>::operator=
@ -208,7 +213,7 @@ void Foam::faPatchField<Type>::write(Ostream& os) const
{
os.writeEntry("type", type());
if (patchType_.size())
if (!patchType_.empty())
{
os.writeEntry("patchType", patchType_);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -45,8 +45,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef faPatchField_H
#define faPatchField_H
#ifndef Foam_faPatchField_H
#define Foam_faPatchField_H
#include "faPatch.H"
#include "DimensionedField.H"
@ -176,7 +176,8 @@ public:
(
const faPatch&,
const DimensionedField<Type, areaMesh>&,
const dictionary&
const dictionary&,
const bool valueRequired=true
);
//- Construct by mapping the given faPatchField onto a new patch

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -38,11 +38,9 @@ Foam::tmp<Foam::faPatchField<Type>> Foam::faPatchField<Type>::New
)
{
DebugInFunction
<< "Constructing faPatchField<Type> "
<< "patchFieldType:" << patchFieldType
<< "actualPatchType:" << actualPatchType
<< "p.Type():" << p.type()
<< endl;
<< "patchFieldType = " << patchFieldType
<< " [" << actualPatchType
<< "] : " << p.type() << " name = " << p.name() << endl;
auto* ctorPtr = patchConstructorTable(patchFieldType);
@ -58,11 +56,7 @@ Foam::tmp<Foam::faPatchField<Type>> Foam::faPatchField<Type>::New
auto* patchTypeCtor = patchConstructorTable(p.type());
if
(
actualPatchType == word::null
|| actualPatchType != p.type()
)
if (actualPatchType.empty() || actualPatchType != p.type())
{
if (patchTypeCtor)
{
@ -106,10 +100,16 @@ Foam::tmp<Foam::faPatchField<Type>> Foam::faPatchField<Type>::New
const dictionary& dict
)
{
DebugInFunction << "Constructing faPatchField<Type>" << endl;
const word patchFieldType(dict.get<word>("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)
@ -130,15 +130,18 @@ Foam::tmp<Foam::faPatchField<Type>> Foam::faPatchField<Type>::New
}
}
auto* patchTypeCtor = dictionaryConstructorTable(p.type());
if (patchTypeCtor && patchTypeCtor != ctorPtr)
if (actualPatchType.empty() || actualPatchType != p.type())
{
FatalIOErrorInFunction(dict)
<< "inconsistent patch and patchField types for \n"
<< " patch type " << p.type()
<< " and patchField type " << patchFieldType
<< exit(FatalIOError);
auto* patchTypeCtor = dictionaryConstructorTable(p.type());
if (patchTypeCtor && patchTypeCtor != ctorPtr)
{
FatalIOErrorInFunction(dict)
<< "inconsistent patch and patchField types for\n"
" patch type " << p.type()
<< " and patchField type " << patchFieldType
<< exit(FatalIOError);
}
}
return ctorPtr(p, iF, dict);
@ -154,7 +157,9 @@ Foam::tmp<Foam::faPatchField<Type>> Foam::faPatchField<Type>::New
const faPatchFieldMapper& pfMapper
)
{
DebugInFunction << "Constructing faPatchField<Type>" << endl;
DebugInFunction
<< "patchFieldType = " << ptf.type()
<< " : " << p.type() << " name = " << p.name() << endl;
auto* ctorPtr = patchMapperConstructorTable(ptf.type());

View File

@ -170,6 +170,11 @@ template<class Type>
void Foam::faePatchField<Type>::write(Ostream& os) const
{
os.writeEntry("type", type());
// if (!patchType_.empty())
// {
// os.writeEntry("patchType", patchType_);
// }
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -220,7 +220,19 @@ public:
// (does not set the patch field values)
static tmp<faePatchField<Type>> New
(
const word&,
const word& patchFieldType,
const faPatch&,
const DimensionedField<Type, edgeMesh>&
);
//- 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<faePatchField<Type>> New
(
const word& patchFieldType,
const word& actualPatchType,
const faPatch&,
const DimensionedField<Type, edgeMesh>&
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,11 +32,15 @@ template<class Type>
Foam::tmp<Foam::faePatchField<Type>> Foam::faePatchField<Type>::New
(
const word& patchFieldType,
const word& actualPatchType,
const faPatch& p,
const DimensionedField<Type, edgeMesh>& iF
)
{
DebugInFunction << "Constructing faePatchField" << endl;
DebugInFunction
<< "patchFieldType = " << patchFieldType
<< " [" << actualPatchType
<< "] : " << p.type() << " name = " << p.name() << endl;
auto* ctorPtr = patchConstructorTable(patchFieldType);
@ -50,16 +54,29 @@ Foam::tmp<Foam::faePatchField<Type>> Foam::faePatchField<Type>::New
) << exit(FatalError);
}
auto* patchTypeCtor = patchConstructorTable(p.type());
if (actualPatchType.empty() || actualPatchType != p.type())
{
auto* patchTypeCtor = patchConstructorTable(p.type());
if (patchTypeCtor)
{
return patchTypeCtor(p, iF);
}
else
{
return ctorPtr(p, iF);
if (patchTypeCtor)
{
return patchTypeCtor(p, iF);
}
}
return ctorPtr(p, iF);
}
template<class Type>
Foam::tmp<Foam::faePatchField<Type>> Foam::faePatchField<Type>::New
(
const word& patchFieldType,
const faPatch& p,
const DimensionedField<Type, edgeMesh>& iF
)
{
return New(patchFieldType, word::null, p, iF);
}
@ -71,10 +88,20 @@ Foam::tmp<Foam::faePatchField<Type>> Foam::faePatchField<Type>::New
const dictionary& dict
)
{
DebugInFunction << "Constructing faePatchField" << endl;
const word patchFieldType(dict.get<word>("type"));
// word actualPatchType;
// dict.readIfPresent("patchType", actualPatchType, keyType::LITERAL);
//
// DebugInFunction
// << "patchFieldType = " << patchFieldType
// << " [" << actualPatchType
// << "] : " << p.type() << " name = " << p.name() << endl;
DebugInFunction
<< "patchFieldType = " << patchFieldType
<< " : " << p.type() << " name = " << p.name() << endl;
auto* ctorPtr = dictionaryConstructorTable(patchFieldType);
if (!ctorPtr)
@ -100,8 +127,8 @@ Foam::tmp<Foam::faePatchField<Type>> Foam::faePatchField<Type>::New
if (patchTypeCtor && patchTypeCtor != ctorPtr)
{
FatalIOErrorInFunction(dict)
<< "inconsistent patch and patchField types for \n"
<< " patch type " << p.type()
<< "inconsistent patch and patchField types for\n"
" patch type " << p.type()
<< " and patchField type " << patchFieldType
<< exit(FatalIOError);
}
@ -119,7 +146,9 @@ Foam::tmp<Foam::faePatchField<Type>> Foam::faePatchField<Type>::New
const faPatchFieldMapper& pfMapper
)
{
DebugInFunction << "Constructing faePatchField<Type>" << endl;
DebugInFunction
<< "patchFieldType = " << ptf.type()
<< " : " << p.type() << " name = " << p.name() << endl;
auto* ctorPtr = patchMapperConstructorTable(ptf.type());

View File

@ -164,7 +164,7 @@ Foam::exprMixedFvPatchField<Type>::exprMixedFvPatchField
driver_.readDict(dict_);
// Similar to fvPatchField constructor, which we have bypassed
dict.readIfPresent("patchType", this->patchType());
dict.readIfPresent("patchType", this->patchType(), keyType::LITERAL);
bool needsRefValue = true;
if (dict.found("refValue"))

View File

@ -256,7 +256,7 @@ void Foam::fixedJumpFvPatchField<Type>::write(Ostream& os) const
fvPatchField<Type>::write(os);
// Write patchType if not done already by fvPatchField
if (!this->patchType().size())
if (this->patchType().empty())
{
os.writeEntry("patchType", this->interfaceFieldType());
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -119,9 +119,12 @@ Foam::fvPatchField<Type>::fvPatchField
internalField_(iF),
updated_(false),
manipulatedMatrix_(false),
useImplicit_(dict.getOrDefault<bool>("useImplicit", false)),
patchType_(dict.getOrDefault<word>("patchType", word::null))
useImplicit_(false),
patchType_()
{
dict.readIfPresent("useImplicit", useImplicit_, keyType::LITERAL);
dict.readIfPresent("patchType", patchType_, keyType::LITERAL);
if (valueRequired)
{
if (dict.found("value"))
@ -134,7 +137,8 @@ Foam::fvPatchField<Type>::fvPatchField
else
{
FatalIOErrorInFunction(dict)
<< "Essential entry 'value' missing on patch " << p.name() << nl
<< "Essential entry 'value' missing on patch "
<< p.name() << endl
<< exit(FatalIOError);
}
}
@ -390,7 +394,7 @@ void Foam::fvPatchField<Type>::write(Ostream& os) const
os.writeEntry("useImplicit", "true");
}
if (patchType_.size())
if (!patchType_.empty())
{
os.writeEntry("patchType", patchType_);
}

View File

@ -68,7 +68,6 @@ template<class Type> class fvPatchField;
template<class Type> class calculatedFvPatchField;
template<class Type> class fvMatrix;
template<class Type>
Ostream& operator<<(Ostream&, const fvPatchField<Type>&);
@ -246,7 +245,7 @@ public:
// (does not set the patch field values)
static tmp<fvPatchField<Type>> New
(
const word&,
const word& patchFieldType,
const fvPatch&,
const DimensionedField<Type, volMesh>&
);
@ -257,7 +256,7 @@ public:
// Allows override of constraint type
static tmp<fvPatchField<Type>> New
(
const word&,
const word& patchFieldType,
const word& actualPatchType,
const fvPatch&,
const DimensionedField<Type, volMesh>&

View File

@ -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.
@ -39,7 +39,8 @@ Foam::tmp<Foam::fvPatchField<Type>> Foam::fvPatchField<Type>::New
{
DebugInFunction
<< "patchFieldType = " << patchFieldType
<< " : " << p.type() << nl;
<< " [" << actualPatchType
<< "] : " << p.type() << " name = " << p.name() << endl;
auto* ctorPtr = patchConstructorTable(patchFieldType);
@ -55,11 +56,7 @@ Foam::tmp<Foam::fvPatchField<Type>> Foam::fvPatchField<Type>::New
auto* patchTypeCtor = patchConstructorTable(p.type());
if
(
actualPatchType == word::null
|| actualPatchType != p.type()
)
if (actualPatchType.empty() || actualPatchType != p.type())
{
if (patchTypeCtor)
{
@ -105,8 +102,13 @@ Foam::tmp<Foam::fvPatchField<Type>> Foam::fvPatchField<Type>::New
{
const word patchFieldType(dict.get<word>("type"));
word actualPatchType;
dict.readIfPresent("patchType", actualPatchType, keyType::LITERAL);
DebugInFunction
<< "patchFieldType = " << patchFieldType << nl;
<< "patchFieldType = " << patchFieldType
<< " [" << actualPatchType
<< "] : " << p.type() << " name = " << p.name() << endl;
auto* ctorPtr = dictionaryConstructorTable(patchFieldType);
@ -128,11 +130,7 @@ Foam::tmp<Foam::fvPatchField<Type>> Foam::fvPatchField<Type>::New
}
}
if
(
!dict.found("patchType")
|| dict.get<word>("patchType") != p.type()
)
if (actualPatchType.empty() || actualPatchType != p.type())
{
auto* patchTypeCtor = dictionaryConstructorTable(p.type());
@ -160,7 +158,8 @@ Foam::tmp<Foam::fvPatchField<Type>> Foam::fvPatchField<Type>::New
)
{
DebugInFunction
<< "Constructing fvPatchField<Type>" << nl;
<< "patchFieldType = " << ptf.type()
<< " : " << p.type() << " name = " << p.name() << endl;
auto* ctorPtr = patchMapperConstructorTable(ptf.type());

View File

@ -81,25 +81,30 @@ Foam::fvsPatchField<Type>::fvsPatchField
(
const fvPatch& p,
const DimensionedField<Type, surfaceMesh>& iF,
const dictionary& dict
const dictionary& dict,
const bool valueRequired
)
:
Field<Type>(p.size()),
patch_(p),
internalField_(iF)
{
if (dict.found("value"))
if (valueRequired)
{
fvsPatchField<Type>::operator=
(
Field<Type>("value", dict, p.size())
);
}
else
{
FatalIOErrorInFunction(dict)
<< "Essential entry 'value' missing on patch " << p.name() << nl
<< exit(FatalIOError);
if (dict.found("value"))
{
fvsPatchField<Type>::operator=
(
Field<Type>("value", dict, p.size())
);
}
else
{
FatalIOErrorInFunction(dict)
<< "Essential entry 'value' missing on patch "
<< p.name() << endl
<< exit(FatalIOError);
}
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -55,21 +55,15 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
// Forward Declarations
class objectRegistry;
class dictionary;
class fvPatchFieldMapper;
class surfaceMesh;
// Forward declaration of friend functions and operators
template<class Type>
class fvsPatchField;
template<class Type>
class calculatedFvsPatchField;
template<class Type> class fvsPatchField;
template<class Type> class calculatedFvsPatchField;
template<class Type>
Ostream& operator<<(Ostream&, const fvsPatchField<Type>&);
@ -170,7 +164,8 @@ public:
(
const fvPatch&,
const DimensionedField<Type, surfaceMesh>&,
const dictionary&
const dictionary&,
const bool valueRequired=true
);
//- Construct by mapping the given fvsPatchField onto a new patch
@ -215,7 +210,7 @@ public:
// (does not set the patch field values)
static tmp<fvsPatchField<Type>> New
(
const word&,
const word& patchFieldType,
const fvPatch&,
const DimensionedField<Type, surfaceMesh>&
);
@ -226,7 +221,7 @@ public:
// Allows override of constraint type
static tmp<fvsPatchField<Type>> New
(
const word&,
const word& patchFieldType,
const word& actualPatchType,
const fvPatch&,
const DimensionedField<Type, surfaceMesh>&

View File

@ -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::tmp<Foam::fvsPatchField<Type>> Foam::fvsPatchField<Type>::New
const DimensionedField<Type, surfaceMesh>& iF
)
{
DebugInFunction << "Constructing fvsPatchField" << endl;
DebugInFunction
<< "patchFieldType = " << patchFieldType
<< " [" << actualPatchType
<< "] : " << p.type() << " name = " << p.name() << endl;
auto* ctorPtr = patchConstructorTable(patchFieldType);
@ -51,11 +54,7 @@ Foam::tmp<Foam::fvsPatchField<Type>> Foam::fvsPatchField<Type>::New
) << exit(FatalError);
}
if
(
actualPatchType == word::null
|| actualPatchType != p.type()
)
if (actualPatchType.empty() || actualPatchType != p.type())
{
auto* patchTypeCtor = patchConstructorTable(p.type());
@ -89,10 +88,16 @@ Foam::tmp<Foam::fvsPatchField<Type>> Foam::fvsPatchField<Type>::New
const dictionary& dict
)
{
DebugInFunction << "Constructing fvsPatchField" << endl;
const word patchFieldType(dict.get<word>("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)
@ -113,11 +118,7 @@ Foam::tmp<Foam::fvsPatchField<Type>> Foam::fvsPatchField<Type>::New
}
}
if
(
!dict.found("patchType")
|| dict.get<word>("patchType") != p.type()
)
if (actualPatchType.empty() || actualPatchType != p.type())
{
auto* patchTypeCtor = dictionaryConstructorTable(p.type());
@ -144,7 +145,9 @@ Foam::tmp<Foam::fvsPatchField<Type>> Foam::fvsPatchField<Type>::New
const fvPatchFieldMapper& pfMapper
)
{
DebugInFunction << "Constructing fvsPatchField" << endl;
DebugInFunction
<< "patchFieldType = " << ptf.type()
<< " : " << p.type() << " name = " << p.name() << endl;
auto* ctorPtr = patchMapperConstructorTable(ptf.type());

View File

@ -329,11 +329,11 @@ void Foam::faMeshDecomposition::decomposeMesh()
).val();
}
// create processor finite area mesh
// Create processor finite area mesh
faMesh procMesh
(
procFvMesh,
procFaceLabels_[procI]
labelList(procFaceLabels_[procI])
);
const uindirectPrimitivePatch& patch = this->patch();
@ -1073,7 +1073,7 @@ void Foam::faMeshDecomposition::decomposeMesh()
faMesh procMesh
(
procFvMesh,
procFaceLabels_[procI]
labelList(procFaceLabels_[procI])
);
@ -1205,7 +1205,7 @@ bool Foam::faMeshDecomposition::writeDecomposition()
faMesh procMesh
(
procFvMesh,
procFaceLabels_[procI]
labelList(procFaceLabels_[procI])
);
// Create processor boundary patches