mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add IOobject-based constructors for meshed surfaces (#1600)
- refactor logic from triSurfaceMesh for triSurface, MeshedSurface, UnsortedMeshedSurface. Makes it easier to locate and use surface files without the triSurfaceMesh (meshTools) infrastructure. STYLE: remove unused sampledTriSurfaceMesh constructors
This commit is contained in:
@ -47,97 +47,6 @@ Foam::word Foam::triSurfaceMesh::meshSubDir = "triSurface";
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fileName Foam::triSurfaceMesh::checkFile
|
|
||||||
(
|
|
||||||
const IOobject& io,
|
|
||||||
const bool isGlobal
|
|
||||||
)
|
|
||||||
{
|
|
||||||
const fileName fName
|
|
||||||
(
|
|
||||||
isGlobal
|
|
||||||
? io.globalFilePath(typeName)
|
|
||||||
: io.localFilePath(typeName)
|
|
||||||
);
|
|
||||||
if (fName.empty())
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot find triSurfaceMesh starting from "
|
|
||||||
<< io.objectPath() << exit(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
return fName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::fileName Foam::triSurfaceMesh::relativeFilePath
|
|
||||||
(
|
|
||||||
const IOobject& io,
|
|
||||||
const fileName& f,
|
|
||||||
const bool isGlobal
|
|
||||||
)
|
|
||||||
{
|
|
||||||
fileName fName(f);
|
|
||||||
fName.expand();
|
|
||||||
if (!fName.isAbsolute())
|
|
||||||
{
|
|
||||||
// Is the specified file:
|
|
||||||
// - local to the cwd?
|
|
||||||
// - local to the case dir?
|
|
||||||
// - or just another name?
|
|
||||||
fName = fileHandler().filePath
|
|
||||||
(
|
|
||||||
isGlobal,
|
|
||||||
IOobject(io, fName),
|
|
||||||
word::null
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return fName;
|
|
||||||
}
|
|
||||||
|
|
||||||
Foam::fileName Foam::triSurfaceMesh::checkFile
|
|
||||||
(
|
|
||||||
const IOobject& io,
|
|
||||||
const dictionary& dict,
|
|
||||||
const bool isGlobal
|
|
||||||
)
|
|
||||||
{
|
|
||||||
fileName fName;
|
|
||||||
if (dict.readIfPresent("file", fName, keyType::LITERAL))
|
|
||||||
{
|
|
||||||
const fileName rawFName(fName);
|
|
||||||
|
|
||||||
fName = relativeFilePath(io, rawFName, isGlobal);
|
|
||||||
|
|
||||||
if (!exists(fName))
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot find triSurfaceMesh " << rawFName
|
|
||||||
<< " starting from " << io.objectPath()
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fName =
|
|
||||||
(
|
|
||||||
isGlobal
|
|
||||||
? io.globalFilePath(typeName)
|
|
||||||
: io.localFilePath(typeName)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!exists(fName))
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot find triSurfaceMesh starting from "
|
|
||||||
<< io.objectPath() << exit(FatalError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return fName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Foam::triSurfaceMesh::addFaceToEdge
|
bool Foam::triSurfaceMesh::addFaceToEdge
|
||||||
(
|
(
|
||||||
const edge& e,
|
const edge& e,
|
||||||
@ -308,7 +217,7 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io)
|
|||||||
false // searchableSurface already registered under name
|
false // searchableSurface already registered under name
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
triSurface(checkFile(static_cast<const searchableSurface&>(*this), true)),
|
triSurface(static_cast<const searchableSurface&>(*this), dictionary::null),
|
||||||
triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
|
triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
|
||||||
minQuality_(-1),
|
minQuality_(-1),
|
||||||
surfaceClosed_(-1),
|
surfaceClosed_(-1),
|
||||||
@ -341,19 +250,16 @@ Foam::triSurfaceMesh::triSurfaceMesh
|
|||||||
false // searchableSurface already registered under name
|
false // searchableSurface already registered under name
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
triSurface
|
triSurface(static_cast<const searchableSurface&>(*this), dict),
|
||||||
(
|
|
||||||
checkFile(static_cast<const searchableSurface&>(*this), dict, true)
|
|
||||||
),
|
|
||||||
triSurfaceRegionSearch(static_cast<const triSurface&>(*this), dict),
|
triSurfaceRegionSearch(static_cast<const triSurface&>(*this), dict),
|
||||||
minQuality_(-1),
|
minQuality_(-1),
|
||||||
surfaceClosed_(-1),
|
surfaceClosed_(-1),
|
||||||
outsideVolType_(volumeType::UNKNOWN)
|
outsideVolType_(volumeType::UNKNOWN)
|
||||||
{
|
{
|
||||||
// Reading from supplied file name instead of objectPath/filePath
|
// Adjust to use supplied file name instead of objectPath/filePath
|
||||||
if (dict.readIfPresent("file", fName_, keyType::LITERAL))
|
if (dict.readIfPresent("file", fName_, keyType::LITERAL))
|
||||||
{
|
{
|
||||||
fName_ = relativeFilePath
|
fName_ = triSurface::relativeFilePath
|
||||||
(
|
(
|
||||||
static_cast<const searchableSurface&>(*this),
|
static_cast<const searchableSurface&>(*this),
|
||||||
fName_,
|
fName_,
|
||||||
@ -404,7 +310,7 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io, const readAction r)
|
|||||||
false // searchableSurface already registered under name
|
false // searchableSurface already registered under name
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
triSurface(), // construct null
|
triSurface(),
|
||||||
triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
|
triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
|
||||||
minQuality_(-1),
|
minQuality_(-1),
|
||||||
surfaceClosed_(-1),
|
surfaceClosed_(-1),
|
||||||
@ -502,7 +408,7 @@ Foam::triSurfaceMesh::triSurfaceMesh
|
|||||||
false // searchableSurface already registered under name
|
false // searchableSurface already registered under name
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
triSurface(), // construct null
|
triSurface(),
|
||||||
triSurfaceRegionSearch(static_cast<const triSurface&>(*this), dict),
|
triSurfaceRegionSearch(static_cast<const triSurface&>(*this), dict),
|
||||||
minQuality_(-1),
|
minQuality_(-1),
|
||||||
surfaceClosed_(-1),
|
surfaceClosed_(-1),
|
||||||
|
|||||||
@ -106,26 +106,6 @@ protected:
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Return fileName to load IOobject from
|
|
||||||
static fileName checkFile(const IOobject& io, const bool isGlobal);
|
|
||||||
|
|
||||||
//- Return fileName. If fileName is relative gets treated local to
|
|
||||||
// IOobject
|
|
||||||
static fileName relativeFilePath
|
|
||||||
(
|
|
||||||
const IOobject&,
|
|
||||||
const fileName&,
|
|
||||||
const bool isGlobal
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Return fileName to load IOobject from. Optional override of fileName
|
|
||||||
static fileName checkFile
|
|
||||||
(
|
|
||||||
const IOobject&,
|
|
||||||
const dictionary&,
|
|
||||||
const bool isGlobal
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Helper function for isSurfaceClosed
|
//- Helper function for isSurfaceClosed
|
||||||
static bool addFaceToEdge
|
static bool addFaceToEdge
|
||||||
(
|
(
|
||||||
|
|||||||
@ -2557,7 +2557,7 @@ Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh(const IOobject& io)
|
|||||||
|
|
||||||
bounds().reduce();
|
bounds().reduce();
|
||||||
|
|
||||||
const fileName actualFile(checkFile(io, true));
|
const fileName actualFile(triSurfaceMesh::checkFile(io, true));
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@ -2697,7 +2697,7 @@ Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh
|
|||||||
|
|
||||||
bounds().reduce();
|
bounds().reduce();
|
||||||
|
|
||||||
const fileName actualFile(checkFile(io, dict, true));
|
const fileName actualFile(triSurfaceMesh::checkFile(io, dict, true));
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -121,32 +122,34 @@ Foam::triSurfaceMeshPointSet::triSurfaceMeshPointSet
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
sampledSet(name, mesh, searchEngine, dict),
|
sampledSet(name, mesh, searchEngine, dict),
|
||||||
surface_(dict.get<word>("surface"))
|
surfaceName_(dict.get<word>("surface"))
|
||||||
{
|
{
|
||||||
// Load surface.
|
// Get or load surface
|
||||||
if (mesh.time().foundObject<triSurfaceMesh>(surface_))
|
|
||||||
|
const auto* surfPtr =
|
||||||
|
mesh.time().cfindObject<triSurfaceMesh>(surfaceName_);
|
||||||
|
|
||||||
|
if (surfPtr)
|
||||||
{
|
{
|
||||||
// Note: should use localPoints() instead of points() but assume
|
// Note: should use localPoints() instead of points() but assume
|
||||||
// trisurface is compact.
|
// trisurface is compact.
|
||||||
sampleCoords_ = mesh.time().lookupObject<triSurfaceMesh>
|
sampleCoords_ = surfPtr->points();
|
||||||
(
|
|
||||||
surface_
|
|
||||||
).points();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sampleCoords_ = triSurfaceMesh
|
sampleCoords_ = triSurface
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
surface_,
|
surfaceName_,
|
||||||
mesh.time().constant(), // instance
|
mesh.time().constant(), // instance
|
||||||
"triSurface", // local
|
"triSurface", // local
|
||||||
mesh.time(),
|
mesh.time(),
|
||||||
IOobject::MUST_READ,
|
IOobject::MUST_READ,
|
||||||
IOobject::NO_WRITE,
|
IOobject::NO_WRITE,
|
||||||
false
|
false
|
||||||
)
|
),
|
||||||
|
dictionary::null
|
||||||
).points();
|
).points();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -60,10 +60,10 @@ class triSurfaceMeshPointSet
|
|||||||
:
|
:
|
||||||
public sampledSet
|
public sampledSet
|
||||||
{
|
{
|
||||||
// Private data
|
// Private Data
|
||||||
|
|
||||||
//- Name of triSurfaceMesh
|
//- The surface name
|
||||||
const word surface_;
|
const word surfaceName_;
|
||||||
|
|
||||||
//- Sampling points
|
//- Sampling points
|
||||||
List<point> sampleCoords_;
|
List<point> sampleCoords_;
|
||||||
|
|||||||
@ -33,7 +33,6 @@ License
|
|||||||
#include "treeDataCell.H"
|
#include "treeDataCell.H"
|
||||||
#include "treeDataFace.H"
|
#include "treeDataFace.H"
|
||||||
#include "meshTools.H"
|
#include "meshTools.H"
|
||||||
|
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
@ -78,8 +77,32 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// The IOobject for reading
|
||||||
|
inline static IOobject selectReadIO(const word& name, const Time& runTime)
|
||||||
|
{
|
||||||
|
return IOobject
|
||||||
|
(
|
||||||
|
name,
|
||||||
|
runTime.constant(), // instance
|
||||||
|
"triSurface", // local
|
||||||
|
runTime, // registry
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false // no register
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -94,14 +117,14 @@ void Foam::sampledTriSurfaceMesh::setZoneMap
|
|||||||
{
|
{
|
||||||
sz += zn.size();
|
sz += zn.size();
|
||||||
}
|
}
|
||||||
|
zoneIds.resize(sz);
|
||||||
|
|
||||||
zoneIds.setSize(sz);
|
|
||||||
forAll(zoneLst, zonei)
|
forAll(zoneLst, zonei)
|
||||||
{
|
{
|
||||||
const surfZone& zn = zoneLst[zonei];
|
const surfZone& zn = zoneLst[zonei];
|
||||||
|
|
||||||
// Assign sub-zone Ids
|
// Assign sub-zone Ids
|
||||||
SubList<label>(zoneIds, zn.size(), zn.start()) = zonei;
|
SubList<label>(zoneIds, zn.range()) = zonei;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,8 +247,8 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
|
|||||||
<< " keeping:" << nFound << endl;
|
<< " keeping:" << nFound << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now subset the surface. Do not use triSurface::subsetMesh since requires
|
// Now subset the surface.
|
||||||
// original surface to be in compact numbering.
|
// Done manually in case the original had non-compact point numbering
|
||||||
|
|
||||||
const triSurface& s = surface_;
|
const triSurface& s = surface_;
|
||||||
|
|
||||||
@ -393,15 +416,10 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
|
|||||||
|
|
||||||
forAll(faceMap, facei)
|
forAll(faceMap, facei)
|
||||||
{
|
{
|
||||||
const labelledTri& origF = s[faceMap[facei]];
|
|
||||||
face& f = surfFaces[facei];
|
face& f = surfFaces[facei];
|
||||||
|
|
||||||
f = triFace
|
f = s[faceMap[facei]]; // Copy original face
|
||||||
(
|
inplaceRenumber(reversePointMap, f); // renumber point ids
|
||||||
reversePointMap[origF[0]],
|
|
||||||
reversePointMap[origF[1]],
|
|
||||||
reversePointMap[origF[2]]
|
|
||||||
);
|
|
||||||
|
|
||||||
for (const label labi : f)
|
for (const label labi : f)
|
||||||
{
|
{
|
||||||
@ -583,18 +601,11 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
|
|||||||
:
|
:
|
||||||
sampledSurface(name, mesh),
|
sampledSurface(name, mesh),
|
||||||
MeshStorage(),
|
MeshStorage(),
|
||||||
|
surfaceName_(surfaceName),
|
||||||
surface_
|
surface_
|
||||||
(
|
(
|
||||||
IOobject
|
selectReadIO(surfaceName, mesh.time()),
|
||||||
(
|
dictionary::null
|
||||||
surfaceName,
|
|
||||||
mesh.time().constant(), // instance
|
|
||||||
"triSurface", // local
|
|
||||||
mesh.time(), // registry
|
|
||||||
IOobject::MUST_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
sampleSource_(sampleSource),
|
sampleSource_(sampleSource),
|
||||||
needsUpdate_(true),
|
needsUpdate_(true),
|
||||||
@ -615,18 +626,17 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
|
|||||||
:
|
:
|
||||||
sampledSurface(name, mesh, dict),
|
sampledSurface(name, mesh, dict),
|
||||||
MeshStorage(),
|
MeshStorage(),
|
||||||
|
surfaceName_
|
||||||
|
(
|
||||||
|
triSurface::findFile
|
||||||
|
(
|
||||||
|
selectReadIO(dict.get<word>("surface"), mesh.time()),
|
||||||
|
dict
|
||||||
|
).name()
|
||||||
|
),
|
||||||
surface_
|
surface_
|
||||||
(
|
(
|
||||||
IOobject
|
selectReadIO(dict.get<word>("surface"), mesh.time()),
|
||||||
(
|
|
||||||
dict.get<word>("surface"),
|
|
||||||
mesh.time().constant(), // instance
|
|
||||||
"triSurface", // local
|
|
||||||
mesh.time(), // registry
|
|
||||||
IOobject::MUST_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
false
|
|
||||||
),
|
|
||||||
dict
|
dict
|
||||||
),
|
),
|
||||||
sampleSource_(samplingSourceNames_.get("source", dict)),
|
sampleSource_(samplingSourceNames_.get("source", dict)),
|
||||||
@ -639,46 +649,6 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
|
|
||||||
(
|
|
||||||
const word& name,
|
|
||||||
const polyMesh& mesh,
|
|
||||||
const triSurface& surface,
|
|
||||||
const word& sampleSourceName
|
|
||||||
)
|
|
||||||
:
|
|
||||||
sampledSurface(name, mesh),
|
|
||||||
MeshStorage(),
|
|
||||||
surface_
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
name,
|
|
||||||
mesh.time().constant(), // instance
|
|
||||||
"triSurface", // local
|
|
||||||
mesh.time(), // registry
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
false
|
|
||||||
),
|
|
||||||
surface
|
|
||||||
),
|
|
||||||
sampleSource_(samplingSourceNames_[sampleSourceName]),
|
|
||||||
needsUpdate_(true),
|
|
||||||
keepIds_(false),
|
|
||||||
originalIds_(),
|
|
||||||
zoneIds_(),
|
|
||||||
sampleElements_(),
|
|
||||||
samplePoints_()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::sampledTriSurfaceMesh::~sampledTriSurfaceMesh()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::sampledTriSurfaceMesh::needsUpdate() const
|
bool Foam::sampledTriSurfaceMesh::needsUpdate() const
|
||||||
@ -700,7 +670,6 @@ bool Foam::sampledTriSurfaceMesh::expire()
|
|||||||
zoneIds_.clear();
|
zoneIds_.clear();
|
||||||
|
|
||||||
originalIds_.clear();
|
originalIds_.clear();
|
||||||
boundaryTreePtr_.clear();
|
|
||||||
sampleElements_.clear();
|
sampleElements_.clear();
|
||||||
samplePoints_.clear();
|
samplePoints_.clear();
|
||||||
|
|
||||||
@ -717,11 +686,7 @@ bool Foam::sampledTriSurfaceMesh::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate surface and mesh overlap bounding box
|
// Calculate surface and mesh overlap bounding box
|
||||||
treeBoundBox bb
|
treeBoundBox bb(surface_.points(), surface_.meshPoints());
|
||||||
(
|
|
||||||
surface_.triSurface::points(),
|
|
||||||
surface_.triSurface::meshPoints()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check for overlap with (global!) mesh bb
|
// Check for overlap with (global!) mesh bb
|
||||||
const bool intersect = bb.intersect(mesh().bounds());
|
const bool intersect = bb.intersect(mesh().bounds());
|
||||||
@ -732,7 +697,7 @@ bool Foam::sampledTriSurfaceMesh::update()
|
|||||||
// bounding box so we don't get any 'invalid bounding box' errors.
|
// bounding box so we don't get any 'invalid bounding box' errors.
|
||||||
|
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "Surface " << surface_.searchableSurface::name()
|
<< "Surface " << surfaceName_
|
||||||
<< " does not overlap bounding box of mesh " << mesh().bounds()
|
<< " does not overlap bounding box of mesh " << mesh().bounds()
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
@ -865,7 +830,7 @@ Foam::tmp<Foam::tensorField> Foam::sampledTriSurfaceMesh::interpolate
|
|||||||
void Foam::sampledTriSurfaceMesh::print(Ostream& os) const
|
void Foam::sampledTriSurfaceMesh::print(Ostream& os) const
|
||||||
{
|
{
|
||||||
os << "sampledTriSurfaceMesh: " << name() << " :"
|
os << "sampledTriSurfaceMesh: " << name() << " :"
|
||||||
<< " surface:" << surface_.objectRegistry::name()
|
<< " surface:" << surfaceName_
|
||||||
<< " faces:" << faces().size()
|
<< " faces:" << faces().size()
|
||||||
<< " points:" << points().size()
|
<< " points:" << points().size()
|
||||||
<< " zoneids:" << zoneIds().size();
|
<< " zoneids:" << zoneIds().size();
|
||||||
|
|||||||
@ -28,8 +28,8 @@ Class
|
|||||||
Foam::sampledTriSurfaceMesh
|
Foam::sampledTriSurfaceMesh
|
||||||
|
|
||||||
Description
|
Description
|
||||||
A sampledSurface from a triSurfaceMesh. It samples on the points/triangles
|
A sampledSurface from a meshed surface.
|
||||||
of the triSurface.
|
It samples on the points/faces of the triSurface.
|
||||||
|
|
||||||
- it either samples cells or (non-coupled) boundary faces
|
- it either samples cells or (non-coupled) boundary faces
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ SourceFiles
|
|||||||
#define sampledTriSurfaceMesh_H
|
#define sampledTriSurfaceMesh_H
|
||||||
|
|
||||||
#include "sampledSurface.H"
|
#include "sampledSurface.H"
|
||||||
#include "triSurfaceMesh.H"
|
#include "triSurface.H"
|
||||||
#include "MeshedSurface.H"
|
#include "MeshedSurface.H"
|
||||||
#include "MeshedSurfacesFwd.H"
|
#include "MeshedSurfacesFwd.H"
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ class sampledTriSurfaceMesh
|
|||||||
public meshedSurface
|
public meshedSurface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//- Types of communications
|
//- Types of sampling regions
|
||||||
enum samplingSource
|
enum samplingSource
|
||||||
{
|
{
|
||||||
cells,
|
cells,
|
||||||
@ -130,7 +130,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//- Private typedefs for convenience
|
//- Private typedefs for convenience
|
||||||
typedef meshedSurface MeshStorage;
|
typedef meshedSurface MeshStorage;
|
||||||
|
|
||||||
|
|
||||||
@ -138,8 +138,11 @@ private:
|
|||||||
|
|
||||||
static const Enum<samplingSource> samplingSourceNames_;
|
static const Enum<samplingSource> samplingSourceNames_;
|
||||||
|
|
||||||
|
//- The name of the input surface
|
||||||
|
word surfaceName_;
|
||||||
|
|
||||||
//- Surface to sample on
|
//- Surface to sample on
|
||||||
const triSurfaceMesh surface_;
|
const triSurface surface_;
|
||||||
|
|
||||||
//- Whether to sample internal cell values or boundary values
|
//- Whether to sample internal cell values or boundary values
|
||||||
const samplingSource sampleSource_;
|
const samplingSource sampleSource_;
|
||||||
@ -151,12 +154,9 @@ private:
|
|||||||
bool keepIds_;
|
bool keepIds_;
|
||||||
|
|
||||||
//- List of element ids/order of the original surface,
|
//- List of element ids/order of the original surface,
|
||||||
// when keepIds is active.
|
//- when keepIds is active.
|
||||||
labelList originalIds_;
|
labelList originalIds_;
|
||||||
|
|
||||||
//- Search tree for all non-coupled boundary faces
|
|
||||||
mutable autoPtr<indexedOctree<treeDataFace>> boundaryTreePtr_;
|
|
||||||
|
|
||||||
//- For compatibility with the meshSurf interface
|
//- For compatibility with the meshSurf interface
|
||||||
labelList zoneIds_;
|
labelList zoneIds_;
|
||||||
|
|
||||||
@ -210,18 +210,9 @@ public:
|
|||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from triSurface
|
|
||||||
sampledTriSurfaceMesh
|
|
||||||
(
|
|
||||||
const word& name,
|
|
||||||
const polyMesh& mesh,
|
|
||||||
const triSurface& surface,
|
|
||||||
const word& sampleSourceName
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~sampledTriSurfaceMesh();
|
virtual ~sampledTriSurfaceMesh() = default;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2018 OpenCFD Ltd.
|
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -67,18 +67,6 @@ Foam::sampledTriSurfaceMeshNormal::sampledTriSurfaceMeshNormal
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
Foam::sampledTriSurfaceMeshNormal::sampledTriSurfaceMeshNormal
|
|
||||||
(
|
|
||||||
const word& name,
|
|
||||||
const polyMesh& mesh,
|
|
||||||
const triSurface& surface,
|
|
||||||
const word& sampleSourceName
|
|
||||||
)
|
|
||||||
:
|
|
||||||
sampledTriSurfaceMesh(name, mesh, surface, sampleSourceName)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::tmp<Foam::Field<Foam::vector>>
|
Foam::tmp<Foam::Field<Foam::vector>>
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2018 OpenCFD Ltd.
|
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -110,15 +110,6 @@ public:
|
|||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from triSurface
|
|
||||||
sampledTriSurfaceMeshNormal
|
|
||||||
(
|
|
||||||
const word& name,
|
|
||||||
const polyMesh& mesh,
|
|
||||||
const triSurface& surface,
|
|
||||||
const word& sampleSourceName
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~sampledTriSurfaceMeshNormal() = default;
|
virtual ~sampledTriSurfaceMeshNormal() = default;
|
||||||
|
|||||||
@ -393,7 +393,11 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
|||||||
|
|
||||||
|
|
||||||
template<class Face>
|
template<class Face>
|
||||||
Foam::MeshedSurface<Face>::MeshedSurface(const fileName& name, const word& ext)
|
Foam::MeshedSurface<Face>::MeshedSurface
|
||||||
|
(
|
||||||
|
const fileName& name,
|
||||||
|
const word& ext
|
||||||
|
)
|
||||||
:
|
:
|
||||||
MeshedSurface<Face>()
|
MeshedSurface<Face>()
|
||||||
{
|
{
|
||||||
@ -419,6 +423,16 @@ Foam::MeshedSurface<Face>::MeshedSurface(Istream& is)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Face>
|
||||||
|
Foam::MeshedSurface<Face>::MeshedSurface
|
||||||
|
(
|
||||||
|
const Time& runTime
|
||||||
|
)
|
||||||
|
:
|
||||||
|
MeshedSurface<Face>(runTime, word::null)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class Face>
|
template<class Face>
|
||||||
Foam::MeshedSurface<Face>::MeshedSurface
|
Foam::MeshedSurface<Face>::MeshedSurface
|
||||||
(
|
(
|
||||||
@ -452,6 +466,31 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Face>
|
||||||
|
Foam::MeshedSurface<Face>::MeshedSurface
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool isGlobal
|
||||||
|
)
|
||||||
|
:
|
||||||
|
MeshedSurface<Face>()
|
||||||
|
{
|
||||||
|
fileName fName
|
||||||
|
(
|
||||||
|
fileFormats::surfaceFormatsCore::checkFile(io, dict, isGlobal)
|
||||||
|
);
|
||||||
|
|
||||||
|
// TBD:
|
||||||
|
// word fExt(dict.getOrDefault<word>("surfaceType", fName.ext()));
|
||||||
|
// read(fName, fExt);
|
||||||
|
|
||||||
|
this->read(fName, fName.ext());
|
||||||
|
|
||||||
|
this->scalePoints(dict.getOrDefault<scalar>("scale", 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Face>
|
template<class Face>
|
||||||
|
|||||||
@ -270,19 +270,32 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from a surfMesh
|
//- Construct from a surfMesh
|
||||||
MeshedSurface(const surfMesh& mesh);
|
explicit MeshedSurface(const surfMesh& mesh);
|
||||||
|
|
||||||
//- Construct from file name (uses extension to determine type)
|
//- Construct from file name (uses extension to determine type)
|
||||||
MeshedSurface(const fileName& name);
|
explicit MeshedSurface(const fileName& name);
|
||||||
|
|
||||||
//- Construct from file name (uses extension to determine type)
|
//- Construct from file name (uses extension to determine type)
|
||||||
MeshedSurface(const fileName& name, const word& ext);
|
explicit MeshedSurface(const fileName& name, const word& ext);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
MeshedSurface(Istream& is);
|
explicit MeshedSurface(Istream& is);
|
||||||
|
|
||||||
//- Construct from database
|
//- Construct from database (as surfMesh) with default name
|
||||||
MeshedSurface(const Time& runTime, const word& surfName = word::null);
|
explicit MeshedSurface(const Time& runTime);
|
||||||
|
|
||||||
|
//- Construct from database (as surfMesh) with given surface name
|
||||||
|
MeshedSurface(const Time& runTime, const word& surfName);
|
||||||
|
|
||||||
|
//- Read construct using IO to find the file location.
|
||||||
|
// Dictionary may contain optional 'file' entry, and an
|
||||||
|
// optional 'scale' entry (eg, 0.001: mm -> m)
|
||||||
|
MeshedSurface
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool isGlobal = true //!< resolve as a global file
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// Declare run-time constructor selection table
|
// Declare run-time constructor selection table
|
||||||
|
|||||||
@ -270,17 +270,55 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
|||||||
template<class Face>
|
template<class Face>
|
||||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||||
(
|
(
|
||||||
const Time& t,
|
const Time& runTime
|
||||||
|
)
|
||||||
|
:
|
||||||
|
UnsortedMeshedSurface<Face>()
|
||||||
|
{
|
||||||
|
MeshedSurface<Face> surf(runTime);
|
||||||
|
transfer(surf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Face>
|
||||||
|
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
const word& surfName
|
const word& surfName
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
UnsortedMeshedSurface<Face>()
|
UnsortedMeshedSurface<Face>()
|
||||||
{
|
{
|
||||||
MeshedSurface<Face> surf(t, surfName);
|
MeshedSurface<Face> surf(runTime, surfName);
|
||||||
transfer(surf);
|
transfer(surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Face>
|
||||||
|
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool isGlobal
|
||||||
|
)
|
||||||
|
:
|
||||||
|
UnsortedMeshedSurface<Face>()
|
||||||
|
{
|
||||||
|
fileName fName
|
||||||
|
(
|
||||||
|
fileFormats::surfaceFormatsCore::checkFile(io, dict, isGlobal)
|
||||||
|
);
|
||||||
|
|
||||||
|
// TBD:
|
||||||
|
// word fExt(dict.getOrDefault<word>("surfaceType", fName.ext()));
|
||||||
|
// read(fName, fExt);
|
||||||
|
|
||||||
|
this->read(fName, fName.ext());
|
||||||
|
|
||||||
|
this->scalePoints(dict.getOrDefault<scalar>("scale", 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Face>
|
template<class Face>
|
||||||
@ -291,19 +329,15 @@ void Foam::UnsortedMeshedSurface<Face>::setOneZone()
|
|||||||
zoneIds_.resize(size());
|
zoneIds_.resize(size());
|
||||||
zoneIds_ = 0;
|
zoneIds_ = 0;
|
||||||
|
|
||||||
word zoneName;
|
|
||||||
if (zoneToc_.size())
|
|
||||||
{
|
|
||||||
zoneName = zoneToc_[0].name();
|
|
||||||
}
|
|
||||||
if (zoneName.empty())
|
|
||||||
{
|
|
||||||
zoneName = "zone0";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign single default zone
|
// Assign single default zone
|
||||||
zoneToc_.resize(1);
|
zoneToc_.resize(1);
|
||||||
zoneToc_[0] = surfZoneIdentifier(zoneName, 0);
|
|
||||||
|
zoneToc_[0].index() = 0;
|
||||||
|
|
||||||
|
if (zoneToc_[0].name().empty())
|
||||||
|
{
|
||||||
|
zoneToc_[0].name() = "zone0";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -324,7 +358,7 @@ void Foam::UnsortedMeshedSurface<Face>::setZones
|
|||||||
zoneToc_[zonei] = zone;
|
zoneToc_[zonei] = zone;
|
||||||
|
|
||||||
// Assign sub-zone Ids
|
// Assign sub-zone Ids
|
||||||
SubList<label>(zoneIds_, zone.size(), zone.start()) = zonei;
|
SubList<label>(zoneIds_, zone.range()) = zonei;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -203,19 +203,28 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from file name (uses extension to determine type)
|
//- Construct from file name (uses extension to determine type)
|
||||||
UnsortedMeshedSurface(const fileName& name);
|
explicit UnsortedMeshedSurface(const fileName& name);
|
||||||
|
|
||||||
//- Construct from file name (uses extension to determine type)
|
//- Construct from file name (uses extension to determine type)
|
||||||
UnsortedMeshedSurface(const fileName& name, const word& ext);
|
UnsortedMeshedSurface(const fileName& name, const word& ext);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
UnsortedMeshedSurface(Istream& is);
|
explicit UnsortedMeshedSurface(Istream& is);
|
||||||
|
|
||||||
//- Construct from objectRegistry and a named surface
|
//- Construct from database (as surfMesh) with default name
|
||||||
|
explicit UnsortedMeshedSurface(const Time& runTime);
|
||||||
|
|
||||||
|
//- Construct from database (as surfMesh) with given surface name
|
||||||
|
UnsortedMeshedSurface(const Time& runTime, const word& surfName);
|
||||||
|
|
||||||
|
//- Read construct using IO to find the file location.
|
||||||
|
// Dictionary may contain optional 'file' entry, and an
|
||||||
|
// optional 'scale' entry (eg, 0.001: mm -> m)
|
||||||
UnsortedMeshedSurface
|
UnsortedMeshedSurface
|
||||||
(
|
(
|
||||||
const Time& t,
|
const IOobject& io,
|
||||||
const word& surfName = word::null
|
const dictionary& dict,
|
||||||
|
const bool isGlobal = true //!< resolve as a global file
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2012 OpenFOAM Foundation
|
Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
Copyright (C) 2017 OpenCFD Ltd.
|
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -27,7 +27,6 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "surfaceFormatsCore.H"
|
#include "surfaceFormatsCore.H"
|
||||||
|
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "ListOps.H"
|
#include "ListOps.H"
|
||||||
#include "Fstream.H"
|
#include "Fstream.H"
|
||||||
@ -157,6 +156,154 @@ Foam::fileName Foam::fileFormats::surfaceFormatsCore::findMeshFile
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileName Foam::fileFormats::surfaceFormatsCore::relativeFilePath
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const fileName& f,
|
||||||
|
const bool isGlobal
|
||||||
|
)
|
||||||
|
{
|
||||||
|
fileName fName(f);
|
||||||
|
fName.expand();
|
||||||
|
if (!fName.isAbsolute())
|
||||||
|
{
|
||||||
|
// Is the specified file:
|
||||||
|
// - local to the cwd?
|
||||||
|
// - local to the case dir?
|
||||||
|
// - or just another name?
|
||||||
|
fName = fileHandler().filePath
|
||||||
|
(
|
||||||
|
isGlobal,
|
||||||
|
IOobject(io, fName),
|
||||||
|
word::null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return fName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileName Foam::fileFormats::surfaceFormatsCore::findFile
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const bool isGlobal
|
||||||
|
)
|
||||||
|
{
|
||||||
|
fileName fName
|
||||||
|
(
|
||||||
|
isGlobal
|
||||||
|
? io.globalFilePath(word::null)
|
||||||
|
: io.localFilePath(word::null)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!exists(fName))
|
||||||
|
{
|
||||||
|
fName.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
return fName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileName Foam::fileFormats::surfaceFormatsCore::findFile
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool isGlobal
|
||||||
|
)
|
||||||
|
{
|
||||||
|
fileName fName;
|
||||||
|
if (dict.readIfPresent("file", fName, keyType::LITERAL))
|
||||||
|
{
|
||||||
|
fName = relativeFilePath(io, fName, isGlobal);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fName =
|
||||||
|
(
|
||||||
|
isGlobal
|
||||||
|
? io.globalFilePath(word::null)
|
||||||
|
: io.localFilePath(word::null)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!exists(fName))
|
||||||
|
{
|
||||||
|
fName.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
return fName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileName Foam::fileFormats::surfaceFormatsCore::checkFile
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const bool isGlobal
|
||||||
|
)
|
||||||
|
{
|
||||||
|
fileName fName
|
||||||
|
(
|
||||||
|
isGlobal
|
||||||
|
? io.globalFilePath(word::null)
|
||||||
|
: io.localFilePath(word::null)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fName.empty())
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Cannot find surface starting from "
|
||||||
|
<< io.objectPath() << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileName Foam::fileFormats::surfaceFormatsCore::checkFile
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool isGlobal
|
||||||
|
)
|
||||||
|
{
|
||||||
|
fileName fName;
|
||||||
|
if (dict.readIfPresent("file", fName, keyType::LITERAL))
|
||||||
|
{
|
||||||
|
const fileName rawFName(fName);
|
||||||
|
|
||||||
|
fName = relativeFilePath(io, rawFName, isGlobal);
|
||||||
|
|
||||||
|
if (!exists(fName))
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Cannot find surface " << rawFName
|
||||||
|
<< " starting from " << io.objectPath() << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fName =
|
||||||
|
(
|
||||||
|
isGlobal
|
||||||
|
? io.globalFilePath(word::null)
|
||||||
|
: io.localFilePath(word::null)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!exists(fName))
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Cannot find surface starting from "
|
||||||
|
<< io.objectPath() << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::fileFormats::surfaceFormatsCore::checkSupport
|
bool Foam::fileFormats::surfaceFormatsCore::checkSupport
|
||||||
(
|
(
|
||||||
const wordHashSet& available,
|
const wordHashSet& available,
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011 OpenFOAM Foundation
|
Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -48,9 +49,12 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declarations
|
// Forward Declarations
|
||||||
class ISstream;
|
class ISstream;
|
||||||
class Time;
|
class Time;
|
||||||
|
class triSurface;
|
||||||
|
class IOobject;
|
||||||
|
class dictionary;
|
||||||
|
|
||||||
namespace fileFormats
|
namespace fileFormats
|
||||||
{
|
{
|
||||||
@ -63,10 +67,15 @@ class surfaceFormatsCore
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
// Friendship with triSurface (for IO helpers)
|
||||||
|
friend class ::Foam::triSurface;
|
||||||
|
|
||||||
|
|
||||||
|
// General
|
||||||
|
|
||||||
//- Read non-empty and non-comment line
|
//- Read non-empty and non-comment line
|
||||||
static string getLineNoComment(ISstream& is, const char comment='#');
|
static string getLineNoComment(ISstream& is, const char comment='#');
|
||||||
|
|
||||||
|
|
||||||
//- Return a surfZone list with a single entry, the size of which
|
//- Return a surfZone list with a single entry, the size of which
|
||||||
//- corresponds to that of the container
|
//- corresponds to that of the container
|
||||||
template<class Container>
|
template<class Container>
|
||||||
@ -76,9 +85,41 @@ protected:
|
|||||||
const word& name = "zone0"
|
const word& name = "zone0"
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return List<surfZone>(1, surfZone(name, container.size(), 0, 0));
|
return List<surfZone>(1, surfZone(name, container.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// IO helpers
|
||||||
|
|
||||||
|
//- Return fileName.
|
||||||
|
// If fileName is relative gets treated as local to IOobject.
|
||||||
|
// Duplicate of triSurfaceMesh::relativeFilePath
|
||||||
|
static fileName relativeFilePath
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const fileName& f,
|
||||||
|
const bool isGlobal = true //!< resolve as a global file
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return fileName to load IOobject from.
|
||||||
|
// Fatal if the file does not exist
|
||||||
|
static fileName checkFile
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const bool isGlobal = true //!< resolve as a global file
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return fileName to load IOobject from.
|
||||||
|
// Supports optional override of fileName with "file" entry
|
||||||
|
// Fatal if the file does not exist
|
||||||
|
static fileName checkFile
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool isGlobal = true //!< resolve as a global file
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Static Data
|
// Static Data
|
||||||
@ -99,39 +140,57 @@ public:
|
|||||||
const word& functionName
|
const word& functionName
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return the local file name (within time directory)
|
//- Use IOobject information to resolve file to load from,
|
||||||
// NEEDS FIXING
|
//- or empty if the file does not exist.
|
||||||
static fileName localMeshFileName
|
static fileName findFile
|
||||||
(
|
(
|
||||||
const word& surfName = word::null
|
const IOobject& io,
|
||||||
|
const bool isGlobal = true //!< resolve as a global file
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Find instance with surfName
|
//- Use IOobject information to resolve file to load from,
|
||||||
// NEEDS FIXING
|
//- or empty if the file does not exist.
|
||||||
static fileName findMeshInstance
|
// Supports optional override of fileName with "file" entry
|
||||||
|
static fileName findFile
|
||||||
(
|
(
|
||||||
const Time&,
|
const IOobject& io,
|
||||||
const word& surfName = word::null
|
const dictionary& dict,
|
||||||
|
const bool isGlobal = true //!< resolve as a global file
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Find mesh file with surfName
|
|
||||||
// NEEDS FIXING
|
// //- Return the local file name (within time directory)
|
||||||
static fileName findMeshFile
|
// // NEEDS FIXING
|
||||||
(
|
// static fileName localMeshFileName
|
||||||
const Time&,
|
// (
|
||||||
const word& surfName = word::null
|
// const word& surfName = word::null
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
|
// //- Find instance with surfName
|
||||||
|
// // NEEDS FIXING
|
||||||
|
// static fileName findMeshInstance
|
||||||
|
// (
|
||||||
|
// const Time&,
|
||||||
|
// const word& surfName = word::null
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// //- Find mesh file with surfName
|
||||||
|
// // NEEDS FIXING
|
||||||
|
// static fileName findMeshFile
|
||||||
|
// (
|
||||||
|
// const Time&,
|
||||||
|
// const word& surfName = word::null
|
||||||
|
// );
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Default construct
|
||||||
surfaceFormatsCore() = default;
|
surfaceFormatsCore() = default;
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~surfaceFormatsCore() = default;
|
virtual ~surfaceFormatsCore() = default;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -504,10 +504,7 @@ Foam::triSurface::triSurface
|
|||||||
const scalar scaleFactor
|
const scalar scaleFactor
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
ParentType(List<Face>(), pointField()),
|
triSurface()
|
||||||
patches_(),
|
|
||||||
sortedEdgeFacesPtr_(nullptr),
|
|
||||||
edgeOwnerPtr_(nullptr)
|
|
||||||
{
|
{
|
||||||
read(name, ext);
|
read(name, ext);
|
||||||
scalePoints(scaleFactor);
|
scalePoints(scaleFactor);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -51,9 +51,9 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declarations
|
// Forward Declarations
|
||||||
|
|
||||||
class Time;
|
class Time;
|
||||||
|
class IOobject;
|
||||||
class IFstream;
|
class IFstream;
|
||||||
class surfZone;
|
class surfZone;
|
||||||
class triSurface;
|
class triSurface;
|
||||||
@ -240,6 +240,54 @@ public:
|
|||||||
static const wordHashSet& writeTypes();
|
static const wordHashSet& writeTypes();
|
||||||
|
|
||||||
|
|
||||||
|
// IO helpers
|
||||||
|
|
||||||
|
//- Return fileName.
|
||||||
|
// If fileName is relative gets treated as local to IOobject.
|
||||||
|
static fileName relativeFilePath
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const fileName& f,
|
||||||
|
const bool isGlobal = true //!< resolve as a global file
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return fileName to load IOobject from.
|
||||||
|
// Fatal if the file does not exist
|
||||||
|
static fileName checkFile
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const bool isGlobal = true //!< resolve as a global file
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return fileName to load IOobject from.
|
||||||
|
// Supports optional override of fileName with "file" entry
|
||||||
|
// Fatal if the file does not exist
|
||||||
|
static fileName checkFile
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool isGlobal = true //!< resolve as a global file
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Use IOobject information to resolve file to load from,
|
||||||
|
//- or empty if the file does not exist.
|
||||||
|
static fileName findFile
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const bool isGlobal = true //!< resolve as a global file
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Use IOobject information to resolve file to load from,
|
||||||
|
//- or empty if the file does not exist.
|
||||||
|
// Supports optional override of fileName with "file" entry
|
||||||
|
static fileName findFile
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool isGlobal = true //!< resolve as a global file
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
@ -286,7 +334,11 @@ public:
|
|||||||
|
|
||||||
//- Construct from file name (uses extension to determine type).
|
//- Construct from file name (uses extension to determine type).
|
||||||
// Optional (positive, non-zero) point scaling is possible.
|
// Optional (positive, non-zero) point scaling is possible.
|
||||||
triSurface(const fileName& name, const scalar scaleFactor = -1);
|
explicit triSurface
|
||||||
|
(
|
||||||
|
const fileName& name,
|
||||||
|
const scalar scaleFactor = -1
|
||||||
|
);
|
||||||
|
|
||||||
//- Construct from file name (uses extension to determine type)
|
//- Construct from file name (uses extension to determine type)
|
||||||
triSurface
|
triSurface
|
||||||
@ -297,10 +349,20 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
triSurface(Istream& is);
|
explicit triSurface(Istream& is);
|
||||||
|
|
||||||
//- Construct from objectRegistry
|
//- Construct from objectRegistry by reading an ".ftr" file
|
||||||
triSurface(const Time& d);
|
explicit triSurface(const Time& d);
|
||||||
|
|
||||||
|
//- Read construct using IO to find the file location.
|
||||||
|
// Dictionary may contain optional 'file' entry, and an
|
||||||
|
// optional 'scale' entry (eg, 0.001: mm -> m)
|
||||||
|
triSurface
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool isGlobal = true //!< resolve as a global file
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017 OpenCFD Ltd.
|
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -104,6 +104,62 @@ bool Foam::triSurface::canRead(const fileName& name, const bool verbose)
|
|||||||
return canReadType(ext, verbose);
|
return canReadType(ext, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileName Foam::triSurface::relativeFilePath
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const fileName& f,
|
||||||
|
const bool isGlobal
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return fileFormats::surfaceFormatsCore::relativeFilePath(io, f, isGlobal);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileName Foam::triSurface::checkFile
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const bool isGlobal
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return fileFormats::surfaceFormatsCore::checkFile(io, isGlobal);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileName Foam::triSurface::checkFile
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool isGlobal
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return fileFormats::surfaceFormatsCore::checkFile(io, dict, isGlobal);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileName Foam::triSurface::findFile
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const bool isGlobal
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return fileFormats::surfaceFormatsCore::findFile(io, isGlobal);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileName Foam::triSurface::findFile
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool isGlobal
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return fileFormats::surfaceFormatsCore::findFile(io, dict, isGlobal);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::triSurface::printTriangle
|
void Foam::triSurface::printTriangle
|
||||||
@ -143,7 +199,8 @@ bool Foam::triSurface::read
|
|||||||
if (check && !exists(name))
|
if (check && !exists(name))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Cannnot read " << name << exit(FatalError);
|
<< "Cannnot read " << name << nl
|
||||||
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ext == "gz")
|
if (ext == "gz")
|
||||||
@ -257,10 +314,7 @@ void Foam::triSurface::write
|
|||||||
|
|
||||||
Foam::triSurface::triSurface(Istream& is)
|
Foam::triSurface::triSurface(Istream& is)
|
||||||
:
|
:
|
||||||
ParentType(List<Face>(), pointField()),
|
triSurface()
|
||||||
patches_(),
|
|
||||||
sortedEdgeFacesPtr_(nullptr),
|
|
||||||
edgeOwnerPtr_(nullptr)
|
|
||||||
{
|
{
|
||||||
read(is);
|
read(is);
|
||||||
|
|
||||||
@ -270,10 +324,7 @@ Foam::triSurface::triSurface(Istream& is)
|
|||||||
|
|
||||||
Foam::triSurface::triSurface(const Time& d)
|
Foam::triSurface::triSurface(const Time& d)
|
||||||
:
|
:
|
||||||
ParentType(List<Face>(), pointField()),
|
triSurface()
|
||||||
patches_(),
|
|
||||||
sortedEdgeFacesPtr_(nullptr),
|
|
||||||
edgeOwnerPtr_(nullptr)
|
|
||||||
{
|
{
|
||||||
fileName foamFile(d.caseName() + ".ftr");
|
fileName foamFile(d.caseName() + ".ftr");
|
||||||
|
|
||||||
@ -287,6 +338,29 @@ Foam::triSurface::triSurface(const Time& d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::triSurface::triSurface
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool isGlobal
|
||||||
|
)
|
||||||
|
:
|
||||||
|
triSurface()
|
||||||
|
{
|
||||||
|
fileName fName(checkFile(io, dict, isGlobal));
|
||||||
|
|
||||||
|
// TBD:
|
||||||
|
// word fileExt = dict.getOrDefault<word>("surfaceType", fName.ext());
|
||||||
|
// read(fName, ext);
|
||||||
|
|
||||||
|
read(fName, fName.ext());
|
||||||
|
|
||||||
|
scalePoints(dict.getOrDefault<scalar>("scale", 0));
|
||||||
|
|
||||||
|
setDefaultPatches();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::triSurface::write
|
void Foam::triSurface::write
|
||||||
|
|||||||
Reference in New Issue
Block a user