mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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.
This commit is contained in:
committed by
Andrew Heather
parent
880d81475b
commit
8037b8d6a8
@ -95,6 +95,7 @@ Foam::sampledSurface::sampledSurface(const word& name, std::nullptr_t)
|
|||||||
name_(name),
|
name_(name),
|
||||||
mesh_(NullObjectRef<polyMesh>()),
|
mesh_(NullObjectRef<polyMesh>()),
|
||||||
enabled_(true),
|
enabled_(true),
|
||||||
|
invariant_(false),
|
||||||
interpolate_(false),
|
interpolate_(false),
|
||||||
area_(-1)
|
area_(-1)
|
||||||
{}
|
{}
|
||||||
@ -110,6 +111,7 @@ Foam::sampledSurface::sampledSurface
|
|||||||
name_(name),
|
name_(name),
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
enabled_(true),
|
enabled_(true),
|
||||||
|
invariant_(false),
|
||||||
interpolate_(interpolate),
|
interpolate_(interpolate),
|
||||||
area_(-1)
|
area_(-1)
|
||||||
{}
|
{}
|
||||||
@ -125,6 +127,7 @@ Foam::sampledSurface::sampledSurface
|
|||||||
name_(dict.lookupOrDefault<word>("name", name)),
|
name_(dict.lookupOrDefault<word>("name", name)),
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
enabled_(dict.lookupOrDefault("enabled", true)),
|
enabled_(dict.lookupOrDefault("enabled", true)),
|
||||||
|
invariant_(dict.lookupOrDefault("invariant", false)),
|
||||||
interpolate_(dict.lookupOrDefault("interpolate", false)),
|
interpolate_(dict.lookupOrDefault("interpolate", false)),
|
||||||
area_(-1)
|
area_(-1)
|
||||||
{}
|
{}
|
||||||
|
|||||||
@ -54,8 +54,15 @@ Description
|
|||||||
name | Alternative name | no |
|
name | Alternative name | no |
|
||||||
enabled | Enable/disable the surface? | no | yes
|
enabled | Enable/disable the surface? | no | yes
|
||||||
interpolate | Sample to nodes instead of faces | no | false
|
interpolate | Sample to nodes instead of faces | no | false
|
||||||
|
invariant | Invariant with geometry change (use with caution!) | no | false
|
||||||
\endtable
|
\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
|
SourceFiles
|
||||||
sampledSurface.C
|
sampledSurface.C
|
||||||
sampledSurfaceTemplates.C
|
sampledSurfaceTemplates.C
|
||||||
@ -110,6 +117,9 @@ private:
|
|||||||
//- Should surface sampling be enabled?
|
//- Should surface sampling be enabled?
|
||||||
bool enabled_;
|
bool enabled_;
|
||||||
|
|
||||||
|
//- Geometry is invariant (never changes)
|
||||||
|
bool invariant_;
|
||||||
|
|
||||||
//- Interpolate information to the nodes?
|
//- Interpolate information to the nodes?
|
||||||
bool interpolate_;
|
bool interpolate_;
|
||||||
|
|
||||||
@ -281,7 +291,13 @@ public:
|
|||||||
return enabled_;
|
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
|
bool interpolate() const
|
||||||
{
|
{
|
||||||
return interpolate_;
|
return interpolate_;
|
||||||
|
|||||||
@ -480,7 +480,7 @@ bool Foam::sampledSurfaces::read(const dictionary& dict)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure all surfaces and merge information are expired
|
// Ensure all surfaces and merge information are expired
|
||||||
expire();
|
expire(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -657,6 +657,7 @@ void Foam::sampledSurfaces::readUpdate(const polyMesh::readUpdateState state)
|
|||||||
{
|
{
|
||||||
if (state != polyMesh::UNCHANGED)
|
if (state != polyMesh::UNCHANGED)
|
||||||
{
|
{
|
||||||
|
// May want to use force expiration here
|
||||||
expire();
|
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
|
// Dimension as fraction of mesh bounding box
|
||||||
const scalar mergeDim = mergeTol_ * mesh_.bounds().mag();
|
const scalar mergeDim = mergeTol_ * mesh_.bounds().mag();
|
||||||
@ -687,6 +688,11 @@ bool Foam::sampledSurfaces::expire()
|
|||||||
{
|
{
|
||||||
sampledSurface& s = (*this)[surfi];
|
sampledSurface& s = (*this)[surfi];
|
||||||
|
|
||||||
|
if (s.invariant() && !force)
|
||||||
|
{
|
||||||
|
// 'Invariant' - does not change when geometry does
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (s.expire())
|
if (s.expire())
|
||||||
{
|
{
|
||||||
++nChanged;
|
++nChanged;
|
||||||
|
|||||||
@ -299,7 +299,9 @@ class sampledSurfaces
|
|||||||
|
|
||||||
//- Mark the surfaces as needing an update.
|
//- Mark the surfaces as needing an update.
|
||||||
// Return false if all surfaces were already marked as expired.
|
// 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.
|
//- Update the surfaces as required.
|
||||||
// Return false if no surfaces required an update.
|
// Return false if no surfaces required an update.
|
||||||
|
|||||||
@ -15,10 +15,10 @@ surfaces
|
|||||||
surfaceFormat vtk;
|
surfaceFormat vtk;
|
||||||
fields (p U Q);
|
fields (p U Q);
|
||||||
|
|
||||||
interpolationScheme cellPoint;
|
// interpolationScheme cellPoint; //<- default
|
||||||
|
|
||||||
surfaces
|
surfaces
|
||||||
(
|
{
|
||||||
zNormal
|
zNormal
|
||||||
{
|
{
|
||||||
type cuttingPlane;
|
type cuttingPlane;
|
||||||
@ -44,8 +44,10 @@ surfaces
|
|||||||
type patch;
|
type patch;
|
||||||
patches ("propeller.*");
|
patches ("propeller.*");
|
||||||
interpolate true;
|
interpolate true;
|
||||||
|
invariant true; // Unaffected by mesh motion
|
||||||
|
surfaceFormat ensight;
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user