mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -2,8 +2,8 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -39,6 +39,8 @@ namespace Foam
|
|||||||
defineTypeNameAndDebug(triSurfaceMesh, 0);
|
defineTypeNameAndDebug(triSurfaceMesh, 0);
|
||||||
addToRunTimeSelectionTable(searchableSurface, triSurfaceMesh, dict);
|
addToRunTimeSelectionTable(searchableSurface, triSurfaceMesh, dict);
|
||||||
|
|
||||||
|
word triSurfaceMesh::meshSubDir = "triSurface";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -231,7 +233,7 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io, const triSurface& s)
|
|||||||
(
|
(
|
||||||
io.name(),
|
io.name(),
|
||||||
io.instance(),
|
io.instance(),
|
||||||
io.local(),
|
io.local(), //"triSurfaceFields",
|
||||||
io.db(),
|
io.db(),
|
||||||
io.readOpt(),
|
io.readOpt(),
|
||||||
io.writeOpt(),
|
io.writeOpt(),
|
||||||
@ -239,9 +241,10 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io, const triSurface& s)
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
triSurface(s),
|
triSurface(s),
|
||||||
triSurfaceRegionSearch(s),
|
triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
|
||||||
minQuality_(-1),
|
minQuality_(-1),
|
||||||
surfaceClosed_(-1)
|
surfaceClosed_(-1),
|
||||||
|
outsideVolType_(volumeType::UNKNOWN)
|
||||||
{
|
{
|
||||||
const pointField& pts = triSurface::points();
|
const pointField& pts = triSurface::points();
|
||||||
|
|
||||||
@ -272,7 +275,7 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io)
|
|||||||
(
|
(
|
||||||
io.name(),
|
io.name(),
|
||||||
static_cast<const searchableSurface&>(*this).instance(),
|
static_cast<const searchableSurface&>(*this).instance(),
|
||||||
io.local(),
|
io.local(), //"triSurfaceFields",
|
||||||
io.db(),
|
io.db(),
|
||||||
io.readOpt(),
|
io.readOpt(),
|
||||||
io.writeOpt(),
|
io.writeOpt(),
|
||||||
@ -289,7 +292,8 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io)
|
|||||||
),
|
),
|
||||||
triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
|
triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
|
||||||
minQuality_(-1),
|
minQuality_(-1),
|
||||||
surfaceClosed_(-1)
|
surfaceClosed_(-1),
|
||||||
|
outsideVolType_(volumeType::UNKNOWN)
|
||||||
{
|
{
|
||||||
const pointField& pts = triSurface::points();
|
const pointField& pts = triSurface::points();
|
||||||
|
|
||||||
@ -323,7 +327,7 @@ Foam::triSurfaceMesh::triSurfaceMesh
|
|||||||
(
|
(
|
||||||
io.name(),
|
io.name(),
|
||||||
static_cast<const searchableSurface&>(*this).instance(),
|
static_cast<const searchableSurface&>(*this).instance(),
|
||||||
io.local(),
|
io.local(), //"triSurfaceFields",
|
||||||
io.db(),
|
io.db(),
|
||||||
io.readOpt(),
|
io.readOpt(),
|
||||||
io.writeOpt(),
|
io.writeOpt(),
|
||||||
@ -340,7 +344,8 @@ Foam::triSurfaceMesh::triSurfaceMesh
|
|||||||
),
|
),
|
||||||
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)
|
||||||
{
|
{
|
||||||
scalar scaleFactor = 0;
|
scalar scaleFactor = 0;
|
||||||
|
|
||||||
@ -377,6 +382,7 @@ Foam::triSurfaceMesh::~triSurfaceMesh()
|
|||||||
|
|
||||||
void Foam::triSurfaceMesh::clearOut()
|
void Foam::triSurfaceMesh::clearOut()
|
||||||
{
|
{
|
||||||
|
outsideVolType_ = volumeType::UNKNOWN;
|
||||||
triSurfaceRegionSearch::clearOut();
|
triSurfaceRegionSearch::clearOut();
|
||||||
edgeTree_.clear();
|
edgeTree_.clear();
|
||||||
triSurface::clearOut();
|
triSurface::clearOut();
|
||||||
@ -447,9 +453,22 @@ bool Foam::triSurfaceMesh::overlaps(const boundBox& bb) const
|
|||||||
|
|
||||||
void Foam::triSurfaceMesh::movePoints(const pointField& newPoints)
|
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();
|
triSurfaceRegionSearch::clearOut();
|
||||||
edgeTree_.clear();
|
edgeTree_.clear();
|
||||||
triSurface::movePoints(newPoints);
|
triSurface::movePoints(newPoints);
|
||||||
|
|
||||||
|
bounds() = boundBox(triSurface::points());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -714,27 +733,41 @@ void Foam::triSurfaceMesh::getNormal
|
|||||||
|
|
||||||
void Foam::triSurfaceMesh::setField(const labelList& values)
|
void Foam::triSurfaceMesh::setField(const labelList& values)
|
||||||
{
|
{
|
||||||
autoPtr<triSurfaceLabelField> fldPtr
|
if (foundObject<triSurfaceLabelField>("values"))
|
||||||
(
|
{
|
||||||
new triSurfaceLabelField
|
triSurfaceLabelField& fld = const_cast<triSurfaceLabelField&>
|
||||||
(
|
(
|
||||||
IOobject
|
lookupObject<triSurfaceLabelField>
|
||||||
(
|
(
|
||||||
"values",
|
"values"
|
||||||
objectRegistry::time().timeName(), // instance
|
)
|
||||||
"triSurface", // local
|
);
|
||||||
|
fld.field() = values;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
autoPtr<triSurfaceLabelField> fldPtr
|
||||||
|
(
|
||||||
|
new triSurfaceLabelField
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"values",
|
||||||
|
objectRegistry::time().timeName(), // instance
|
||||||
|
meshSubDir, // local
|
||||||
|
*this,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
*this,
|
*this,
|
||||||
IOobject::NO_READ,
|
dimless,
|
||||||
IOobject::AUTO_WRITE
|
labelField(values)
|
||||||
),
|
)
|
||||||
*this,
|
);
|
||||||
dimless,
|
|
||||||
labelField(values)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Store field on triMesh
|
// Store field on triMesh
|
||||||
fldPtr.ptr()->store();
|
fldPtr.ptr()->store();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -781,17 +814,26 @@ void Foam::triSurfaceMesh::getVolumeType
|
|||||||
|
|
||||||
if (!tree().bb().contains(pt))
|
if (!tree().bb().contains(pt))
|
||||||
{
|
{
|
||||||
// Have to calculate directly as outside the octree
|
if (hasVolumeType())
|
||||||
volType[pointI] = tree().shapes().getVolumeType(tree(), pt);
|
{
|
||||||
|
// 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
|
else
|
||||||
{
|
{
|
||||||
// - use cached volume type per each tree node
|
// - use cached volume type per each tree node
|
||||||
volType[pointI] = tree().getVolumeType(pt);
|
volType[pointI] = tree().getVolumeType(pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Info<< "octree : " << pt << " = "
|
|
||||||
// << volumeType::names[volType[pointI]] << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
indexedOctree<treeDataTriSurface>::perturbTol() = oldTol;
|
indexedOctree<treeDataTriSurface>::perturbTol() = oldTol;
|
||||||
@ -806,6 +848,24 @@ bool Foam::triSurfaceMesh::writeObject
|
|||||||
IOstream::compressionType cmp
|
IOstream::compressionType cmp
|
||||||
) const
|
) 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());
|
fileName fullPath(searchableSurface::objectPath());
|
||||||
|
|
||||||
if (!mkDir(fullPath.path()))
|
if (!mkDir(fullPath.path()))
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -85,6 +85,9 @@ private:
|
|||||||
//- Is surface closed
|
//- Is surface closed
|
||||||
mutable label surfaceClosed_;
|
mutable label surfaceClosed_;
|
||||||
|
|
||||||
|
//- If surface is closed, what is type of outside points
|
||||||
|
mutable volumeType outsideVolType_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
@ -137,6 +140,9 @@ public:
|
|||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
TypeName("triSurfaceMesh");
|
TypeName("triSurfaceMesh");
|
||||||
|
|
||||||
|
//- Return the mesh sub-directory name (usually "triSurface")
|
||||||
|
static word meshSubDir;
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user