BUG: triSurfaceMesh: fix writing to time directory

Also various speed ups to do with getting volume type outside of bounding box.
This commit is contained in:
mattijs
2015-10-14 11:36:35 +01:00
committed by Andrew Heather
parent 06e3b9c4c4
commit f1b22fa163
2 changed files with 98 additions and 32 deletions

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,6 +39,8 @@ namespace Foam
defineTypeNameAndDebug(triSurfaceMesh, 0);
addToRunTimeSelectionTable(searchableSurface, triSurfaceMesh, dict);
word triSurfaceMesh::meshSubDir = "triSurface";
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -231,7 +233,7 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io, const triSurface& s)
(
io.name(),
io.instance(),
io.local(),
io.local(), //"triSurfaceFields",
io.db(),
io.readOpt(),
io.writeOpt(),
@ -239,9 +241,10 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io, const triSurface& s)
)
),
triSurface(s),
triSurfaceRegionSearch(s),
triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
minQuality_(-1),
surfaceClosed_(-1)
surfaceClosed_(-1),
outsideVolType_(volumeType::UNKNOWN)
{
const pointField& pts = triSurface::points();
@ -272,7 +275,7 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io)
(
io.name(),
static_cast<const searchableSurface&>(*this).instance(),
io.local(),
io.local(), //"triSurfaceFields",
io.db(),
io.readOpt(),
io.writeOpt(),
@ -289,7 +292,8 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io)
),
triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
minQuality_(-1),
surfaceClosed_(-1)
surfaceClosed_(-1),
outsideVolType_(volumeType::UNKNOWN)
{
const pointField& pts = triSurface::points();
@ -323,7 +327,7 @@ Foam::triSurfaceMesh::triSurfaceMesh
(
io.name(),
static_cast<const searchableSurface&>(*this).instance(),
io.local(),
io.local(), //"triSurfaceFields",
io.db(),
io.readOpt(),
io.writeOpt(),
@ -340,7 +344,8 @@ Foam::triSurfaceMesh::triSurfaceMesh
),
triSurfaceRegionSearch(static_cast<const triSurface&>(*this), dict),
minQuality_(-1),
surfaceClosed_(-1)
surfaceClosed_(-1),
outsideVolType_(volumeType::UNKNOWN)
{
scalar scaleFactor = 0;
@ -377,6 +382,7 @@ Foam::triSurfaceMesh::~triSurfaceMesh()
void Foam::triSurfaceMesh::clearOut()
{
outsideVolType_ = volumeType::UNKNOWN;
triSurfaceRegionSearch::clearOut();
edgeTree_.clear();
triSurface::clearOut();
@ -447,9 +453,22 @@ bool Foam::triSurfaceMesh::overlaps(const boundBox& bb) const
void Foam::triSurfaceMesh::movePoints(const pointField& newPoints)
{
outsideVolType_ = volumeType::UNKNOWN;
// Update local information (instance, event number)
searchableSurface::instance() = objectRegistry::time().timeName();
objectRegistry::instance() = searchableSurface::instance();
label event = getEvent();
searchableSurface::eventNo() = event;
objectRegistry::eventNo() = searchableSurface::eventNo();
// Clear additional addressing
triSurfaceRegionSearch::clearOut();
edgeTree_.clear();
triSurface::movePoints(newPoints);
bounds() = boundBox(triSurface::points());
}
@ -714,6 +733,19 @@ void Foam::triSurfaceMesh::getNormal
void Foam::triSurfaceMesh::setField(const labelList& values)
{
if (foundObject<triSurfaceLabelField>("values"))
{
triSurfaceLabelField& fld = const_cast<triSurfaceLabelField&>
(
lookupObject<triSurfaceLabelField>
(
"values"
)
);
fld.field() = values;
}
else
{
autoPtr<triSurfaceLabelField> fldPtr
(
new triSurfaceLabelField
@ -722,7 +754,7 @@ void Foam::triSurfaceMesh::setField(const labelList& values)
(
"values",
objectRegistry::time().timeName(), // instance
"triSurface", // local
meshSubDir, // local
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
@ -735,6 +767,7 @@ void Foam::triSurfaceMesh::setField(const labelList& values)
// Store field on triMesh
fldPtr.ptr()->store();
}
}
@ -780,18 +813,27 @@ void Foam::triSurfaceMesh::getVolumeType
const point& pt = points[pointI];
if (!tree().bb().contains(pt))
{
if (hasVolumeType())
{
// Precalculate and cache value for this outside point
if (outsideVolType_ == volumeType::UNKNOWN)
{
outsideVolType_ = tree().shapes().getVolumeType(tree(), pt);
}
volType[pointI] = outsideVolType_;
}
else
{
// Have to calculate directly as outside the octree
volType[pointI] = tree().shapes().getVolumeType(tree(), pt);
}
}
else
{
// - use cached volume type per each tree node
volType[pointI] = tree().getVolumeType(pt);
}
// Info<< "octree : " << pt << " = "
// << volumeType::names[volType[pointI]] << endl;
}
indexedOctree<treeDataTriSurface>::perturbTol() = oldTol;
@ -806,6 +848,24 @@ bool Foam::triSurfaceMesh::writeObject
IOstream::compressionType cmp
) const
{
const Time& runTime = searchableSurface::time();
const fileName& instance = searchableSurface::instance();
if
(
instance != runTime.timeName()
&& instance != runTime.system()
&& instance != runTime.caseSystem()
&& instance != runTime.constant()
&& instance != runTime.caseConstant()
)
{
const_cast<triSurfaceMesh&>(*this).searchableSurface::instance() =
runTime.timeName();
const_cast<triSurfaceMesh&>(*this).objectRegistry::instance() =
runTime.timeName();
}
fileName fullPath(searchableSurface::objectPath());
if (!mkDir(fullPath.path()))

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,6 +85,9 @@ private:
//- Is surface closed
mutable label surfaceClosed_;
//- If surface is closed, what is type of outside points
mutable volumeType outsideVolType_;
// Private Member Functions
@ -137,6 +140,9 @@ public:
//- Runtime type information
TypeName("triSurfaceMesh");
//- Return the mesh sub-directory name (usually "triSurface")
static word meshSubDir;
// Constructors