ENH: Refactored the dummyFvMesh code

This commit is contained in:
Andrew Heather 2018-06-05 16:10:04 +01:00
parent a3228f861a
commit 3530711219
11 changed files with 611 additions and 239 deletions

View File

@ -1,4 +1,3 @@
Info<< "Constructing single cell mesh" << nl << endl; Info<< "Constructing single cell mesh" << nl << endl;
autoPtr<fvMesh> meshPtr = dummyFvMesh::singleCellMesh(runTime); Foam::proxyMeshes::hexCellFvMesh mesh(runTime);
fvMesh& mesh = meshPtr();

View File

@ -9,7 +9,7 @@ if (args.optionFound("dry-run") || args.optionFound("dry-run-write"))
Foam::FieldBase::allowConstructFromLargerSize = true; Foam::FieldBase::allowConstructFromLargerSize = true;
// Create a simplified 1D mesh and attempt to re-create boundary conditions // Create a simplified 1D mesh and attempt to re-create boundary conditions
meshPtr.reset(Foam::dummyFvMesh::equivalent1DMesh(runTime)); meshPtr.reset(new Foam::proxyMeshes::columnFvMesh(runTime));
// Stopping after 1 iteration of the simplified mesh // Stopping after 1 iteration of the simplified mesh
// Note: using saNoWriteNow will only trigger the function object execute // Note: using saNoWriteNow will only trigger the function object execute

View File

@ -3,7 +3,9 @@ fvMesh/fvMesh.C
fvMesh/singleCellFvMesh/singleCellFvMesh.C fvMesh/singleCellFvMesh/singleCellFvMesh.C
fvMesh/dummyFvMesh/dummyFvMesh.C fvMesh/proxyFvMesh/proxyFvMesh.C
fvMesh/proxyFvMesh/columnFvMesh.C
fvMesh/proxyFvMesh/hexCellFvMesh.C
fvBoundaryMesh = fvMesh/fvBoundaryMesh fvBoundaryMesh = fvMesh/fvBoundaryMesh
$(fvBoundaryMesh)/fvBoundaryMesh.C $(fvBoundaryMesh)/fvBoundaryMesh.C

View File

@ -21,7 +21,10 @@
#include "findRefCell.H" #include "findRefCell.H"
#include "IOMRFZoneList.H" #include "IOMRFZoneList.H"
#include "constants.H" #include "constants.H"
#include "dummyFvMesh.H"
#include "proxyFvMesh.H"
#include "columnFvMesh.H"
#include "hexCellFvMesh.H"
#include "OSspecific.H" #include "OSspecific.H"
#include "argList.H" #include "argList.H"

View File

@ -23,122 +23,45 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "dummyFvMesh.H" #include "columnFvMesh.H"
#include "Time.H"
#include "polyBoundaryMeshEntries.H" #include "polyBoundaryMeshEntries.H"
#include "IOobjectList.H" #include "IOobjectList.H"
#include "fieldDictionary.H" #include "fieldDictionary.H"
#include "topoSet.H" #include "vectorIOField.H"
#include "calculatedFvPatchField.H"
#include "emptyPolyPatch.H" #include "emptyPolyPatch.H"
#include "processorPolyPatch.H" #include "topoSet.H"
#include "processorCyclicPolyPatch.H" #include "addToRunTimeSelectionTable.H"
#include "cyclicPolyPatch.H"
#include "cyclicAMIPolyPatch.H"
#include "cyclicACMIPolyPatch.H"
#include "fvPatchField.H"
#include "pointPatchField.H"
// * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(dummyFvMesh, 0); namespace proxyMeshes
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::dummyFvMesh::fvPatchFieldExists(const word& patchType)
{ {
if defineTypeNameAndDebug(columnFvMeshInfo, 0);
( defineTypeNameAndDebug(columnFvMesh, 0);
fvPatchField<scalar>::dictionaryConstructorTablePtr_->found(patchType)
|| fvPatchField<vector>::dictionaryConstructorTablePtr_->found(patchType)
|| fvPatchField<sphericalTensor>::
dictionaryConstructorTablePtr_->found(patchType)
|| fvPatchField<symmTensor>::
dictionaryConstructorTablePtr_->found(patchType)
|| fvPatchField<tensor>::dictionaryConstructorTablePtr_->found(patchType)
)
{
return true;
}
return false; addToRunTimeSelectionTable
(
proxyFvMesh,
columnFvMesh,
time
);
} }
Foam::autoPtr<Foam::fvMesh> Foam::dummyFvMesh::singleCellMesh
(
const Time& runTime,
const scalar d
)
{
pointField points(8);
points[0] = vector(0, 0, 0);
points[1] = vector(d, 0, 0);
points[2] = vector(d, d, 0);
points[3] = vector(0, d, 0);
points[4] = vector(0, 0, d);
points[5] = vector(d, 0, d);
points[6] = vector(d, d, d);
points[7] = vector(0, d, d);
faceList faces = cellModel::ref(cellModel::HEX).modelFaces();
autoPtr<fvMesh> meshPtr
(
new Foam::fvMesh
(
IOobject
(
polyMesh::defaultRegion,
runTime.timeName(),
runTime,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
std::move(points),
std::move(faces),
labelList(6, Zero),
labelList()
)
);
fvMesh& mesh = meshPtr();
List<polyPatch*> patches(1);
patches[0] = new emptyPolyPatch
(
"boundary",
6,
0,
0,
mesh.boundaryMesh(),
emptyPolyPatch::typeName
);
mesh.addFvPatches(patches);
return meshPtr;
} }
bool Foam::dummyFvMesh::setPatchEntries // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::proxyMeshes::columnFvMeshInfo::setPatchEntries
( (
const Time& runTime, const Time& runTime
const word& instance,
dictionary& patchEntries,
label& nPatchWithFace
) )
{ {
IOobject boundaryIO IOobject boundaryIO
( (
"boundary", "boundary",
instance, localInstance_,
polyMesh::meshSubDir, polyMesh::meshSubDir,
runTime, runTime,
IOobject::MUST_READ, IOobject::MUST_READ,
@ -152,7 +75,7 @@ bool Foam::dummyFvMesh::setPatchEntries
{ {
polyBoundaryMeshEntries allPatchEntries(boundaryIO); polyBoundaryMeshEntries allPatchEntries(boundaryIO);
Info<< "Creating dummy mesh using " << allPatchEntries.path() << endl; Info<< "Creating proxy mesh using " << allPatchEntries.path() << endl;
for (const entry& e : allPatchEntries) for (const entry& e : allPatchEntries)
{ {
@ -162,9 +85,9 @@ bool Foam::dummyFvMesh::setPatchEntries
{ {
if (readLabel(e.dict().lookup("nFaces"))) if (readLabel(e.dict().lookup("nFaces")))
{ {
++nPatchWithFace; ++nPatchWithFace_;
} }
patchEntries.add(e.keyword(), e.dict()); patchEntries_.add(e.keyword(), e.dict());
} }
} }
@ -192,7 +115,7 @@ bool Foam::dummyFvMesh::setPatchEntries
const fieldDictionary fieldDict(io, io.headerClassName()); const fieldDictionary fieldDict(io, io.headerClassName());
Info<< "Creating dummy mesh from field " Info<< "Creating proxy mesh from field "
<< fieldDict.objectPath() << fieldDict.objectPath()
<< endl; << endl;
@ -203,17 +126,17 @@ bool Foam::dummyFvMesh::setPatchEntries
{ {
const word type(e.dict().lookup("type")); const word type(e.dict().lookup("type"));
if (fvPatchFieldExists(type)) if (proxyFvMesh::fvPatchFieldExists(type))
{ {
if (!constraintPatches.found(type)) if (!constraintPatches.found(type))
{ {
++nPatchWithFace; ++nPatchWithFace_;
dictionary dummyEntries; dictionary proxyEntries;
dummyEntries.add("startFace", 0); proxyEntries.add("startFace", 0);
dummyEntries.add("nFaces", 1); proxyEntries.add("nFaces", 1);
dummyEntries.add("type", "wall"); // default to wall type proxyEntries.add("type", "wall"); // default to wall type
patchEntries.add(e.keyword(), dummyEntries); patchEntries_.add(e.keyword(), proxyEntries);
} }
} }
else else
@ -227,28 +150,14 @@ bool Foam::dummyFvMesh::setPatchEntries
} }
Foam::autoPtr<Foam::fvMesh> Foam::dummyFvMesh::equivalent1DMesh void Foam::proxyMeshes::columnFvMeshInfo::initialise(const Time& runTime)
(
const Time& runTime
)
{ {
DebugInfo << "Constructing 1-D mesh" << nl << endl; DebugInfo << "Constructing 1-D mesh" << nl << endl;
const word instance =
runTime.findInstance
(
polyMesh::meshSubDir,
"boundary",
IOobject::READ_IF_PRESENT
);
// Read patches - filter out proc patches for parallel runs // Read patches - filter out proc patches for parallel runs
dictionary patchEntries; createFromMesh_ = setPatchEntries(runTime);
label nPatchWithFace = 0;
bool createFromMesh =
setPatchEntries(runTime, instance, patchEntries, nPatchWithFace);
const label nPatch = patchEntries.size(); const label nPatch = patchEntries_.size();
DebugPout << "Read " << nPatch << " patches" << endl; DebugPout << "Read " << nPatch << " patches" << endl;
@ -272,11 +181,11 @@ Foam::autoPtr<Foam::fvMesh> Foam::dummyFvMesh::equivalent1DMesh
// - rotational cyclic - convert to separated and warn not handled? // - rotational cyclic - convert to separated and warn not handled?
// - proc patches - faces need to be collocated? // - proc patches - faces need to be collocated?
pointField points(nPatchWithFace*4 + 4); points1D_.setSize(nPatchWithFace_*4 + 4);
faceList faces(nPatchWithFace*5 + 1); faces1D_.setSize(nPatchWithFace_*5 + 1);
labelList owner(faces.size(), label(-1)); owner1D_.setSize(faces1D_.size(), label(-1));
labelList neighbour(owner); neighbour1D_.setSize(owner1D_.size(), label(-1));
vector dx(Zero); vector dx(Zero);
{ {
@ -284,7 +193,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::dummyFvMesh::equivalent1DMesh
IOobject pointsIO IOobject pointsIO
( (
"points", "points",
instance, localInstance_,
polyMesh::meshSubDir, polyMesh::meshSubDir,
runTime, runTime,
IOobject::MUST_READ, IOobject::MUST_READ,
@ -307,7 +216,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::dummyFvMesh::equivalent1DMesh
origin = meshBb.min(); origin = meshBb.min();
vector span = meshBb.span(); vector span = meshBb.span();
dxi = span.x()/scalar(nPatchWithFace); dxi = span.x()/scalar(nPatchWithFace_);
dyi = span.y(); dyi = span.y();
dzi = span.z(); dzi = span.z();
} }
@ -315,7 +224,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::dummyFvMesh::equivalent1DMesh
{ {
scalar Lref = GREAT; scalar Lref = GREAT;
origin = point(-Lref, -Lref, -Lref); origin = point(-Lref, -Lref, -Lref);
dxi = 2.0*Lref/scalar(nPatchWithFace); dxi = 2.0*Lref/scalar(nPatchWithFace_);
dyi = Lref; dyi = Lref;
dzi = Lref; dzi = Lref;
} }
@ -325,109 +234,139 @@ Foam::autoPtr<Foam::fvMesh> Foam::dummyFvMesh::equivalent1DMesh
const vector dz(0, 0, dzi); const vector dz(0, 0, dzi);
// End face // End face
points[0] = origin; points1D_[0] = origin;
points[1] = origin + dy; points1D_[1] = origin + dy;
points[2] = origin + dy + dz; points1D_[2] = origin + dy + dz;
points[3] = origin + dz; points1D_[3] = origin + dz;
} }
label n = 4; label n = 4;
for (label i = 1; i <= nPatchWithFace; ++i) for (label i = 1; i <= nPatchWithFace_; ++i)
{ {
const vector idx(i*dx); const vector idx(i*dx);
points[i*n] = points[0] + idx; points1D_[i*n] = points1D_[0] + idx;
points[i*n + 1] = points[1] + idx; points1D_[i*n + 1] = points1D_[1] + idx;
points[i*n + 2] = points[2] + idx; points1D_[i*n + 2] = points1D_[2] + idx;
points[i*n + 3] = points[3] + idx; points1D_[i*n + 3] = points1D_[3] + idx;
} }
if (debug) Pout<< "points:" << points << endl; if (debug) Pout<< "points:" << points1D_ << endl;
label facei = 0; label facei = 0;
// Internal faces first // Internal faces first
for (label i = 0; i < nPatchWithFace - 1; ++i) for (label i = 0; i < nPatchWithFace_ - 1; ++i)
{ {
label o = i*4; label o = i*4;
faces[facei] = face({4 + o, 5 + o, 6 + o, 7 + o}); faces1D_[facei] = face({4 + o, 5 + o, 6 + o, 7 + o});
owner[facei] = i; owner1D_[facei] = i;
neighbour[facei] = i + 1; neighbour1D_[facei] = i + 1;
++facei; ++facei;
} }
// Boundary conditions // Boundary conditions
for (label i = 0; i < nPatchWithFace; ++i) for (label i = 0; i < nPatchWithFace_; ++i)
{ {
label o = i*4; label o = i*4;
faces[facei] = face({0 + o, 4 + o, 7 + o, 3 + o}); faces1D_[facei] = face({0 + o, 4 + o, 7 + o, 3 + o});
owner[facei] = i; owner1D_[facei] = i;
++facei; ++facei;
faces[facei] = face({0 + o, 1 + o, 5 + o, 4 + o}); faces1D_[facei] = face({0 + o, 1 + o, 5 + o, 4 + o});
owner[facei] = i; owner1D_[facei] = i;
++facei; ++facei;
faces[facei] = face({1 + o, 2 + o, 6 + o, 5 + o}); faces1D_[facei] = face({1 + o, 2 + o, 6 + o, 5 + o});
owner[facei] = i; owner1D_[facei] = i;
++facei; ++facei;
faces[facei] = face({3 + o, 7 + o, 6 + o, 2 + o}); faces1D_[facei] = face({3 + o, 7 + o, 6 + o, 2 + o});
owner[facei] = i; owner1D_[facei] = i;
++facei; ++facei;
} }
{ {
// End caps // End caps
faces[facei] = face({0, 3, 2, 1}); faces1D_[facei] = face({0, 3, 2, 1});
owner[facei] = 0; owner1D_[facei] = 0;
++facei; ++facei;
label o = 4*nPatchWithFace; label o = 4*nPatchWithFace_;
faces[facei] = face({0 + o, 1 + o, 2 + o, 3 + o}); faces1D_[facei] = face({0 + o, 1 + o, 2 + o, 3 + o});
owner[facei] = nPatchWithFace - 1; owner1D_[facei] = nPatchWithFace_ - 1;
++facei; ++facei;
} }
DebugPout DebugPout
<< "faces:" << faces << nl << "faces:" << faces1D_ << nl
<< "owner:" << owner << nl << "owner:" << owner1D_ << nl
<< "neighbour:" << neighbour << "neighbour:" << neighbour1D_
<< endl; << endl;
}
autoPtr<fvMesh> meshPtr
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::proxyMeshes::columnFvMeshInfo::columnFvMeshInfo(const Time& runTime)
:
localInstance_
( (
new Foam::fvMesh runTime.findInstance
( (
IOobject polyMesh::meshSubDir,
( "boundary",
fvMesh::defaultRegion, IOobject::READ_IF_PRESENT
runTime.constant(),
runTime,
IOobject::NO_READ, // Do not read any existing mesh
IOobject::NO_WRITE
),
std::move(points),
std::move(faces),
std::move(owner),
std::move(neighbour)
) )
); ),
createFromMesh_(false),
points1D_(),
faces1D_(),
owner1D_(),
neighbour1D_(),
patchEntries_(),
nPatchWithFace_(0)
{
initialise(runTime);
}
Foam::fvMesh& mesh = meshPtr();
// Workaround to read fvSchemes and fvSolution Foam::proxyMeshes::columnFvMesh::columnFvMesh(const Time& runTime)
:
columnFvMeshInfo(runTime),
proxyFvMesh
(
IOobject
(
fvMesh::defaultRegion,
runTime.constant(),
runTime,
IOobject::NO_READ, // Do not read any existing mesh
IOobject::NO_WRITE
),
std::move(points1D_),
std::move(faces1D_),
std::move(owner1D_),
std::move(neighbour1D_)
)
{
// Workaround to read fvSchemes and fvSolution after setting NO_READ
// when creating the mesh
{ {
mesh.fvSchemes::readOpt() = IOobject::MUST_READ; fvSchemes::readOpt() = IOobject::MUST_READ;
mesh.fvSchemes::read(); fvSchemes::read();
mesh.fvSolution::readOpt() = IOobject::MUST_READ; fvSolution::readOpt() = IOobject::MUST_READ;
mesh.fvSolution::read(); fvSolution::read();
} }
// Add the patches
const label nPatch = patchEntries_.size();
List<polyPatch*> patches(nPatch + 1); List<polyPatch*> patches(nPatch + 1);
label nInternalFace = nPatchWithFace - 1; label nInternalFace = nPatchWithFace_ - 1;
label startFace = nInternalFace; label startFace = nInternalFace;
label entryi = 0; label entryi = 0;
for (const entry& e : patchEntries) for (const entry& e : patchEntries_)
{ {
// Re-create boundary types, but reset nFaces and startFace settings // Re-create boundary types, but reset nFaces and startFace settings
dictionary patchDict = e.dict(); dictionary patchDict = e.dict();
@ -451,7 +390,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::dummyFvMesh::equivalent1DMesh
patchName, patchName,
patchDict, patchDict,
entryi, entryi,
mesh.boundaryMesh() boundaryMesh()
).ptr(); ).ptr();
++entryi; ++entryi;
@ -462,13 +401,13 @@ Foam::autoPtr<Foam::fvMesh> Foam::dummyFvMesh::equivalent1DMesh
( (
typeName + ":default", // name typeName + ":default", // name
2, // number of faces 2, // number of faces
nInternalFace + 4*nPatchWithFace, // start face nInternalFace + 4*nPatchWithFace_, // start face
nPatch - 1, // index in boundary list nPatch - 1, // index in boundary list
mesh.boundaryMesh(), // polyBoundaryMesh boundaryMesh(), // polyBoundaryMesh
emptyPolyPatch::typeName // patchType emptyPolyPatch::typeName // patchType
); );
mesh.addFvPatches(patches); addFvPatches(patches);
if (debug) if (debug)
{ {
@ -480,12 +419,14 @@ Foam::autoPtr<Foam::fvMesh> Foam::dummyFvMesh::equivalent1DMesh
} }
} }
if (createFromMesh) // Add the zones
if (createFromMesh_)
{ {
// Initialise the zones // Initialise the zones
initialiseZone<pointZoneMesh>("point", instance, mesh.pointZones()); initialiseZone<pointZoneMesh>("point", localInstance_, pointZones());
initialiseZone<faceZoneMesh>("face", instance, mesh.faceZones()); initialiseZone<faceZoneMesh>("face", localInstance_, faceZones());
initialiseZone<cellZoneMesh>("cell", instance, mesh.cellZones()); initialiseZone<cellZoneMesh>("cell", localInstance_, cellZones());
// Dummy sets created on demand // Dummy sets created on demand
topoSet::disallowGenericSets = 1; topoSet::disallowGenericSets = 1;
@ -499,11 +440,9 @@ Foam::autoPtr<Foam::fvMesh> Foam::dummyFvMesh::equivalent1DMesh
if (debug) if (debug)
{ {
mesh.setInstance(runTime.timeName()); setInstance(runTime.timeName());
mesh.objectRegistry::write(); objectRegistry::write();
} }
return meshPtr;
} }

View File

@ -0,0 +1,133 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ 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 <http://www.gnu.org/licenses/>.
Class
Foam::proxyMeshes::columnFvMesh
Description
Generates a 1D column representation of a mesh based on an existing mesh
and/or fields
SourceFiles
columnFvMesh.C
\*---------------------------------------------------------------------------*/
#ifndef proxyMeshes_columnFvMesh_H
#define proxyMeshes_columnFvMesh_H
#include "proxyFvMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace proxyMeshes
{
/*---------------------------------------------------------------------------*\
Class columnFvMesh Declaration
\*---------------------------------------------------------------------------*/
class columnFvMeshInfo
{
// Private Member Funtions
//- Set the patch dictionary entries using the mesh or field files
bool setPatchEntries(const Time& runTime);
//- Initialise
void initialise(const Time& runTime);
protected:
// Protected data
//- Location of existing mesh (if present)
const word localInstance_;
//- Created from existing mesh (false = from field)
bool createFromMesh_;
// Temporary mesh data used during construction of columnFvMesh
// Note: transferred to columnFvMesh
//- Points
pointField points1D_;
//- Faces
faceList faces1D_;
//- Owner addressing
labelList owner1D_;
//- Neighbour addressing
labelList neighbour1D_;
// Patch data
//- Dictionary of patch information
dictionary patchEntries_;
//- Number of patches with at least 1 local face
label nPatchWithFace_;
public:
//- Runtime type information
ClassName("columnFvMeshInfo");
// Constructor
columnFvMeshInfo(const Time& runTime);
};
class columnFvMesh
:
public columnFvMeshInfo,
public proxyFvMesh
{
public:
//- Runtime type information
TypeName("columnFvMesh");
//- Constructor
columnFvMesh(const Time& runTime);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace proxyMeshes
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,100 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "hexCellFvMesh.H"
#include "emptyPolyPatch.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * //
namespace Foam
{
namespace proxyMeshes
{
defineTypeNameAndDebug(hexCellFvMesh, 0);
addToRunTimeSelectionTable
(
proxyFvMesh,
hexCellFvMesh,
time
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::proxyMeshes::hexCellFvMesh::hexCellFvMesh
(
const Time& runTime,
const scalar d
)
:
proxyFvMesh
(
IOobject
(
polyMesh::defaultRegion,
runTime.timeName(),
runTime,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
pointField
(
{
point(0, 0, 0),
point(d, 0, 0),
point(d, d, 0),
point(0, d, 0),
point(0, 0, d),
point(d, 0, d),
point(d, d, d),
point(0, d, d)
}
),
faceList(cellModel::ref(cellModel::HEX).modelFaces()),
labelList(6, Zero),
labelList()
)
{
List<polyPatch*> patches(1);
patches[0] = new emptyPolyPatch
(
"boundary",
6,
0,
0,
boundaryMesh(),
emptyPolyPatch::typeName
);
addFvPatches(patches);
}
// ************************************************************************* //

View File

@ -0,0 +1,75 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ 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 <http://www.gnu.org/licenses/>.
Class
Foam::proxyMeshes::hexCellFvMesh
Description
Generates a single hex cell representation of a mesh
SourceFiles
hexCellFvMesh.C
\*---------------------------------------------------------------------------*/
#ifndef proxyMeshes_hexCellFvMesh_H
#define proxyMeshes_hexCellFvMesh_H
#include "proxyFvMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace proxyMeshes
{
/*---------------------------------------------------------------------------*\
Class hexCellFvMesh Declaration
\*---------------------------------------------------------------------------*/
class hexCellFvMesh
:
public proxyFvMesh
{
public:
//- Runtime type information
TypeName("hexCellFvMesh");
//- Constructor
hexCellFvMesh(const Time& runTime, const scalar d = 1);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace proxyMeshes
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,104 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "proxyFvMesh.H"
#include "fvPatchField.H"
// * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(proxyFvMesh, 0);
defineRunTimeSelectionTable(proxyFvMesh, time);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::proxyFvMesh::fvPatchFieldExists(const word& patchType)
{
if
(
fvPatchField<scalar>::dictionaryConstructorTablePtr_->found(patchType)
|| fvPatchField<vector>::dictionaryConstructorTablePtr_->found(patchType)
|| fvPatchField<sphericalTensor>::
dictionaryConstructorTablePtr_->found(patchType)
|| fvPatchField<symmTensor>::
dictionaryConstructorTablePtr_->found(patchType)
|| fvPatchField<tensor>::dictionaryConstructorTablePtr_->found(patchType)
)
{
return true;
}
return false;
}
Foam::proxyFvMesh::proxyFvMesh
(
const IOobject& io,
pointField&& points,
faceList&& faces,
labelList&& allOwner,
labelList&& allNeighbour
)
:
fvMesh
(
io,
std::move(points),
std::move(faces),
std::move(allOwner),
std::move(allNeighbour)
)
{}
Foam::autoPtr<Foam::proxyFvMesh> Foam::proxyFvMesh::New
(
const word& modelType,
const Time& runTime
)
{
Info<< "Selecting proxy mesh model " << modelType << endl;
auto cstrIter = timeConstructorTablePtr_->cfind(modelType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown proxy mesh type "
<< modelType << nl << nl
<< "Valid dumy meshes :" << endl
<< timeConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<proxyFvMesh>(cstrIter()(runTime));
}
// ************************************************************************* //

View File

@ -22,54 +22,41 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::dummyFvMesh Foam::proxyFvMesh
Description Description
Functions to generate dummy finite volume meshes Functions to generate proxy finite volume meshes
SourceFiles SourceFiles
dummyFvMesh.C proxyFvMesh.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef dummyFvMesh_H #ifndef proxyFvMesh_H
#define dummyFvMesh_H #define proxyFvMesh_H
#include "className.H" #include "runTimeSelectionTables.H"
#include "autoPtr.H" #include "fvMesh.H"
#include "HashSet.H" #include "Time.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
class fvMesh;
class Time;
template<class Type> class List;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class dummyFvMesh Declaration Class proxyFvMesh Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class dummyFvMesh class proxyFvMesh
:
public fvMesh
{ {
//- Helper function to see if the patch type exists in the run-time protected:
//- selection tables
static bool fvPatchFieldExists(const word& patchType);
//- Set the patch information. Returns true if setting based on a real mesh
static bool setPatchEntries
(
const Time& runTime,
const word& instance,
dictionary& patchEntries,
label& nPatchWithFace
);
//- Helper function to initialise empty zones //- Helper function to initialise empty zones
template<class ZoneMeshType> template<class ZoneMeshType>
static void initialiseZone void initialiseZone
( (
const word& zoneTypeName, const word& zoneTypeName,
const fileName& instance, const fileName& instance,
@ -79,19 +66,49 @@ class dummyFvMesh
public: public:
ClassName("dummyFvMesh"); //- Runtime type information
TypeName("proxyFvMesh");
//- Create a single cell mesh with empty boundary conditions all-round // Declare run-time constructor selection table
static autoPtr<fvMesh> singleCellMesh
declareRunTimeSelectionTable
(
autoPtr,
proxyFvMesh,
time,
(
const Time& runTime
),
(runTime)
);
// Selectors
//- Return a reference to the selected proxy mesh
static autoPtr<proxyFvMesh> New
(
const word& modelType,
const Time& runTime
);
//- Constructor
proxyFvMesh
( (
const Time& runTime, const IOobject& io,
const scalar d = 1 pointField&& points,
faceList&& faces,
labelList&& allOwner,
labelList&& allNeighbour
); );
//- Create an equivalent 1D mesh using the same boundary types as
//- described in the polyMesh/boundary file, complete with (empty) // Member Functions
//- [point|face|cell] zones
static autoPtr<fvMesh> equivalent1DMesh(const Time& runTime); //- Helper function to see if the patch type exists in the run-time
//- selection tables
static bool fvPatchFieldExists(const word& patchType);
}; };
@ -102,7 +119,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository #ifdef NoRepository
#include "dummyFvMeshTemplates.C" #include "proxyFvMeshTemplates.C"
#endif #endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -26,7 +26,7 @@ License
#include "polyMesh.H" #include "polyMesh.H"
template<class ZoneMeshType> template<class ZoneMeshType>
void Foam::dummyFvMesh::initialiseZone void Foam::proxyFvMesh::initialiseZone
( (
const word& zoneTypeName, const word& zoneTypeName,
const fileName& instance, const fileName& instance,