Commit 8037b8d6 authored by Mark Olesen's avatar Mark Olesen Committed by Andrew Heather
Browse files

ENH: allow invariant surfaces for sampling (#1418)

- an advanced feature, for example when sampling on a static patch
  while some motion occurs elsewhere. [use with caution]

- If the sampled surface dictionary is modified during run-time, the
  ensight file indexing for the geometry will become out of sync.
  This is addressed in a subsequent commit.
parent 880d8147
......@@ -95,6 +95,7 @@ Foam::sampledSurface::sampledSurface(const word& name, std::nullptr_t)
name_(name),
mesh_(NullObjectRef<polyMesh>()),
enabled_(true),
invariant_(false),
interpolate_(false),
area_(-1)
{}
......@@ -110,6 +111,7 @@ Foam::sampledSurface::sampledSurface
name_(name),
mesh_(mesh),
enabled_(true),
invariant_(false),
interpolate_(interpolate),
area_(-1)
{}
......@@ -125,6 +127,7 @@ Foam::sampledSurface::sampledSurface
name_(dict.lookupOrDefault<word>("name", name)),
mesh_(mesh),
enabled_(dict.lookupOrDefault("enabled", true)),
invariant_(dict.lookupOrDefault("invariant", false)),
interpolate_(dict.lookupOrDefault("interpolate", false)),
area_(-1)
{}
......
......@@ -54,8 +54,15 @@ Description
name | Alternative name | no |
enabled | Enable/disable the surface? | no | yes
interpolate | Sample to nodes instead of faces | no | false
invariant | Invariant with geometry change (use with caution!) | no | false
\endtable
Note
The invariant switch is an advanced feature to declare that the surface is
unaffected by changes in the general mesh geometry. For example, if sampling
on a static patch while some other motion occurs elsewhere. If used improperly,
there is a significant possibility for problems (caveat emptor).
SourceFiles
sampledSurface.C
sampledSurfaceTemplates.C
......@@ -110,6 +117,9 @@ private:
//- Should surface sampling be enabled?
bool enabled_;
//- Geometry is invariant (never changes)
bool invariant_;
//- Interpolate information to the nodes?
bool interpolate_;
......@@ -281,7 +291,13 @@ public:
return enabled_;
}
//- interpolation to nodes requested for surface
//- Surface is invariant with geometry change (caution)
bool invariant() const
{
return invariant_;
}
//- Interpolation to nodes requested for surface
bool interpolate() const
{
return interpolate_;
......
......@@ -480,7 +480,7 @@ bool Foam::sampledSurfaces::read(const dictionary& dict)
}
// Ensure all surfaces and merge information are expired
expire();
expire(true);
return true;
}
......@@ -657,6 +657,7 @@ void Foam::sampledSurfaces::readUpdate(const polyMesh::readUpdateState state)
{
if (state != polyMesh::UNCHANGED)
{
// May want to use force expiration here
expire();
}
}
......@@ -676,7 +677,7 @@ bool Foam::sampledSurfaces::needsUpdate() const
}
bool Foam::sampledSurfaces::expire()
bool Foam::sampledSurfaces::expire(const bool force)
{
// Dimension as fraction of mesh bounding box
const scalar mergeDim = mergeTol_ * mesh_.bounds().mag();
......@@ -687,6 +688,11 @@ bool Foam::sampledSurfaces::expire()
{
sampledSurface& s = (*this)[surfi];
if (s.invariant() && !force)
{
// 'Invariant' - does not change when geometry does
continue;
}
if (s.expire())
{
++nChanged;
......
......@@ -299,7 +299,9 @@ class sampledSurfaces
//- Mark the surfaces as needing an update.
// Return false if all surfaces were already marked as expired.
virtual bool expire();
// Optionally force expire, even if a surface has been marked as
// invariant.
virtual bool expire(const bool force=false);
//- Update the surfaces as required.
// Return false if no surfaces required an update.
......
......@@ -15,10 +15,10 @@ surfaces
surfaceFormat vtk;
fields (p U Q);
interpolationScheme cellPoint;
// interpolationScheme cellPoint; //<- default
surfaces
(
{
zNormal
{
type cuttingPlane;
......@@ -44,8 +44,10 @@ surfaces
type patch;
patches ("propeller.*");
interpolate true;
invariant true; // Unaffected by mesh motion
surfaceFormat ensight;
}
);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment