mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: avoid updating sampled surfaces unless necessary
This commit is contained in:
committed by
Andrew Heather
parent
e2228aab8a
commit
647a86b7d1
@ -164,19 +164,18 @@ void Foam::sampledSurfaces::countFields()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now propagate field counts (per surface)
|
// Now propagate field counts (per surface)
|
||||||
|
// - can update writer even when not writing without problem
|
||||||
|
|
||||||
label surfi = 0;
|
forAll(*this, surfi)
|
||||||
|
|
||||||
for (const sampledSurface& s : surfaces())
|
|
||||||
{
|
{
|
||||||
|
const sampledSurface& s = (*this)[surfi];
|
||||||
|
|
||||||
writers_[surfi].nFields() =
|
writers_[surfi].nFields() =
|
||||||
(
|
(
|
||||||
nVolumeFields
|
nVolumeFields
|
||||||
+ (s.withSurfaceFields() ? nSurfaceFields : 0)
|
+ (s.withSurfaceFields() ? nSurfaceFields : 0)
|
||||||
+ ((s.hasFaceIds() && !s.interpolate()) ? 1 : 0)
|
+ ((s.hasFaceIds() && !s.interpolate()) ? 1 : 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
++surfi;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,9 +445,10 @@ bool Foam::sampledSurfaces::read(const dictionary& dict)
|
|||||||
dict.readEntry("fields", fieldSelection_);
|
dict.readEntry("fields", fieldSelection_);
|
||||||
fieldSelection_.uniq();
|
fieldSelection_.uniq();
|
||||||
|
|
||||||
label surfi = 0;
|
forAll(*this, surfi)
|
||||||
for (const sampledSurface& s : surfs)
|
|
||||||
{
|
{
|
||||||
|
const sampledSurface& s = (*this)[surfi];
|
||||||
|
|
||||||
if (!surfi)
|
if (!surfi)
|
||||||
{
|
{
|
||||||
Info<< "Sampled surface:" << nl;
|
Info<< "Sampled surface:" << nl;
|
||||||
@ -465,8 +465,6 @@ bool Foam::sampledSurfaces::read(const dictionary& dict)
|
|||||||
Info<< ", store as surfMesh (deprecated)";
|
Info<< ", store as surfMesh (deprecated)";
|
||||||
}
|
}
|
||||||
Info<< nl;
|
Info<< nl;
|
||||||
|
|
||||||
++surfi;
|
|
||||||
}
|
}
|
||||||
Info<< nl;
|
Info<< nl;
|
||||||
}
|
}
|
||||||
@ -492,36 +490,34 @@ bool Foam::sampledSurfaces::read(const dictionary& dict)
|
|||||||
|
|
||||||
bool Foam::sampledSurfaces::performAction(unsigned request)
|
bool Foam::sampledSurfaces::performAction(unsigned request)
|
||||||
{
|
{
|
||||||
if
|
// Update surfaces, writer associations etc.
|
||||||
(
|
|
||||||
empty()
|
bool ok = false;
|
||||||
|| (request == ACTION_NONE)
|
|
||||||
|| !testAny
|
forAll(*this, surfi)
|
||||||
(
|
|
||||||
actions_,
|
|
||||||
[=] (unsigned action) { return (request & action); }
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
sampledSurface& s = (*this)[surfi];
|
||||||
|
|
||||||
|
if (request & actions_[surfi])
|
||||||
|
{
|
||||||
|
if (s.update())
|
||||||
|
{
|
||||||
|
writers_[surfi].expire();
|
||||||
|
}
|
||||||
|
|
||||||
|
nFaces_[surfi] = returnReduce(s.faces().size(), sumOp<label>());
|
||||||
|
|
||||||
|
ok = ok || nFaces_[surfi];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
// No surface with faces or an applicable action
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Finalize surfaces, update information, writer associations etc.
|
|
||||||
update();
|
|
||||||
|
|
||||||
bool noFaces = true;
|
|
||||||
for (const label n : nFaces_)
|
|
||||||
{
|
|
||||||
if (n) noFaces = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (noFaces)
|
|
||||||
{
|
|
||||||
// No surfaces with faces at all.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine the per-surface number of fields, including Ids etc.
|
// Determine the per-surface number of fields, including Ids etc.
|
||||||
// Only seems to be needed for VTK legacy
|
// Only seems to be needed for VTK legacy
|
||||||
countFields();
|
countFields();
|
||||||
@ -531,6 +527,15 @@ bool Foam::sampledSurfaces::performAction(unsigned request)
|
|||||||
{
|
{
|
||||||
const sampledSurface& s = (*this)[surfi];
|
const sampledSurface& s = (*this)[surfi];
|
||||||
|
|
||||||
|
if (!(request & actions_[surfi]))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TDB: do we store empty surfaces, skip them, or remove them
|
||||||
|
// from the registry?
|
||||||
|
// - For now, just skip touching them.
|
||||||
|
|
||||||
if (!nFaces_[surfi])
|
if (!nFaces_[surfi])
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@ -689,10 +694,10 @@ bool Foam::sampledSurfaces::expire()
|
|||||||
|
|
||||||
label nChanged = 0;
|
label nChanged = 0;
|
||||||
|
|
||||||
label surfi = 0;
|
forAll(*this, surfi)
|
||||||
|
|
||||||
for (sampledSurface& s : surfaces())
|
|
||||||
{
|
{
|
||||||
|
sampledSurface& s = (*this)[surfi];
|
||||||
|
|
||||||
if (s.expire())
|
if (s.expire())
|
||||||
{
|
{
|
||||||
++nChanged;
|
++nChanged;
|
||||||
@ -701,8 +706,6 @@ bool Foam::sampledSurfaces::expire()
|
|||||||
writers_[surfi].expire();
|
writers_[surfi].expire();
|
||||||
writers_[surfi].mergeDim() = mergeDim;
|
writers_[surfi].mergeDim() = mergeDim;
|
||||||
nFaces_[surfi] = 0;
|
nFaces_[surfi] = 0;
|
||||||
|
|
||||||
++surfi;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// True if any surfaces just expired
|
// True if any surfaces just expired
|
||||||
@ -719,10 +722,10 @@ bool Foam::sampledSurfaces::update()
|
|||||||
|
|
||||||
label nUpdated = 0;
|
label nUpdated = 0;
|
||||||
|
|
||||||
label surfi = 0;
|
forAll(*this, surfi)
|
||||||
|
|
||||||
for (sampledSurface& s : surfaces())
|
|
||||||
{
|
{
|
||||||
|
sampledSurface& s = (*this)[surfi];
|
||||||
|
|
||||||
if (s.update())
|
if (s.update())
|
||||||
{
|
{
|
||||||
++nUpdated;
|
++nUpdated;
|
||||||
@ -730,8 +733,6 @@ bool Foam::sampledSurfaces::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
nFaces_[surfi] = returnReduce(s.faces().size(), sumOp<label>());
|
nFaces_[surfi] = returnReduce(s.faces().size(), sumOp<label>());
|
||||||
|
|
||||||
++surfi;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nUpdated;
|
return nUpdated;
|
||||||
|
|||||||
Reference in New Issue
Block a user