diff --git a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C index f8d5a7a3a0..bb50eb9219 100644 --- a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C +++ b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C @@ -95,6 +95,7 @@ Foam::sampledSurface::sampledSurface(const word& name, std::nullptr_t) name_(name), mesh_(NullObjectRef()), 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("name", name)), mesh_(mesh), enabled_(dict.lookupOrDefault("enabled", true)), + invariant_(dict.lookupOrDefault("invariant", false)), interpolate_(dict.lookupOrDefault("interpolate", false)), area_(-1) {} diff --git a/src/sampling/sampledSurface/sampledSurface/sampledSurface.H b/src/sampling/sampledSurface/sampledSurface/sampledSurface.H index ba6a84a15f..3eeb7c97c0 100644 --- a/src/sampling/sampledSurface/sampledSurface/sampledSurface.H +++ b/src/sampling/sampledSurface/sampledSurface/sampledSurface.H @@ -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_; diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index 0fe8f62af4..f16c65f035 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -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; diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H index 84406abbfd..13d4440f97 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H @@ -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. diff --git a/tutorials/incompressible/pimpleFoam/RAS/propeller/system/surfaces b/tutorials/incompressible/pimpleFoam/RAS/propeller/system/surfaces index 13d5145f28..3badd4b7d2 100644 --- a/tutorials/incompressible/pimpleFoam/RAS/propeller/system/surfaces +++ b/tutorials/incompressible/pimpleFoam/RAS/propeller/system/surfaces @@ -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; } - ); + } }