Bugfix in samplesCuttingPlane

Need to trigger the re-calculation of cutting plane on topo changes
This commit is contained in:
Vuko Vukcevic 2018-04-24 16:03:09 +02:00
parent d7a357b646
commit 8a14f3ce8e
4 changed files with 38 additions and 21 deletions

View file

@ -105,6 +105,7 @@ class isoSurface
//- Reference to mesh //- Reference to mesh
const fvMesh& mesh_; const fvMesh& mesh_;
//- Point values
const scalarField& pVals_; const scalarField& pVals_;
//- Input volScalarField with separated coupled patches rewritten //- Input volScalarField with separated coupled patches rewritten
@ -119,7 +120,6 @@ class isoSurface
//- When to merge points //- When to merge points
const scalar mergeDistance_; const scalar mergeDistance_;
//- Whether face might be cut //- Whether face might be cut
List<cellCutType> faceCutType_; List<cellCutType> faceCutType_;
@ -446,7 +446,6 @@ public:
const GeometricField<Type, fvPatchField, volMesh>& cCoords, const GeometricField<Type, fvPatchField, volMesh>& cCoords,
const Field<Type>& pCoords const Field<Type>& pCoords
) const; ) const;
}; };

View file

@ -572,13 +572,13 @@ bool Foam::sampledIsoSurface::expire()
facesPtr_.clear(); facesPtr_.clear();
subMeshPtr_.clear(); subMeshPtr_.clear();
// already marked as expired // Already marked as expired
if (prevTimeIndex_ == -1) if (prevTimeIndex_ == -1)
{ {
return false; return false;
} }
// force update // Force update
prevTimeIndex_ = -1; prevTimeIndex_ = -1;
return true; return true;
} }

View file

@ -61,6 +61,8 @@ void Foam::sampledCuttingPlane::createGeometry()
pointDistance_.clear(); pointDistance_.clear();
cellDistancePtr_.clear(); cellDistancePtr_.clear();
// Clear derived data
clearGeom();
// Get any subMesh // Get any subMesh
if (zoneID_.index() != -1 && !subMeshPtr_.valid()) if (zoneID_.index() != -1 && !subMeshPtr_.valid())
@ -311,6 +313,12 @@ Foam::sampledCuttingPlane::~sampledCuttingPlane()
bool Foam::sampledCuttingPlane::needsUpdate() const bool Foam::sampledCuttingPlane::needsUpdate() const
{ {
// Update for changing mesh
if (mesh().changing())
{
needsUpdate_ = true;
}
return needsUpdate_; return needsUpdate_;
} }
@ -327,6 +335,9 @@ bool Foam::sampledCuttingPlane::expire()
// Clear any stored topologies // Clear any stored topologies
facesPtr_.clear(); facesPtr_.clear();
// Clear derived data
clearGeom();
// already marked as expired // already marked as expired
if (needsUpdate_) if (needsUpdate_)
{ {

View file

@ -68,10 +68,10 @@ class sampledCuttingPlane
//- Whether to recalculate cell values as average of point values //- Whether to recalculate cell values as average of point values
const Switch average_; const Switch average_;
//- zone name/index (if restricted to zones) //- Zone name/index (if restricted to zones)
mutable cellZoneID zoneID_; mutable cellZoneID zoneID_;
//- for zones: patch to put exposed faces into //- For zones: patch to put exposed faces into
mutable word exposedPatchName_; mutable word exposedPatchName_;
//- Track if the surface needs an update //- Track if the surface needs an update
@ -90,7 +90,7 @@ class sampledCuttingPlane
//- Constructed iso surface //- Constructed iso surface
autoPtr<isoSurface> isoSurfPtr_; autoPtr<isoSurface> isoSurfPtr_;
//- triangles converted to faceList //- Triangles converted to faceList
mutable autoPtr<faceList> facesPtr_; mutable autoPtr<faceList> facesPtr_;
@ -99,7 +99,7 @@ class sampledCuttingPlane
//- Create iso surface //- Create iso surface
void createGeometry(); void createGeometry();
//- sample field on faces //- Sample field on faces
template <class Type> template <class Type>
tmp<Field<Type> > sampleField tmp<Field<Type> > sampleField
( (
@ -129,9 +129,8 @@ public:
); );
// Destructor //- Destructor
virtual ~sampledCuttingPlane();
virtual ~sampledCuttingPlane();
// Member Functions // Member Functions
@ -177,67 +176,75 @@ public:
return isoSurfPtr_(); return isoSurfPtr_();
} }
//- sample field on surface
// Sample
//- Sample field on surface
virtual tmp<scalarField> sample virtual tmp<scalarField> sample
( (
const volScalarField& const volScalarField&
) const; ) const;
//- sample field on surface //- Sample field on surface
virtual tmp<vectorField> sample virtual tmp<vectorField> sample
( (
const volVectorField& const volVectorField&
) const; ) const;
//- sample field on surface //- Sample field on surface
virtual tmp<sphericalTensorField> sample virtual tmp<sphericalTensorField> sample
( (
const volSphericalTensorField& const volSphericalTensorField&
) const; ) const;
//- sample field on surface //- Sample field on surface
virtual tmp<symmTensorField> sample virtual tmp<symmTensorField> sample
( (
const volSymmTensorField& const volSymmTensorField&
) const; ) const;
//- sample field on surface //- Sample field on surface
virtual tmp<tensorField> sample virtual tmp<tensorField> sample
( (
const volTensorField& const volTensorField&
) const; ) const;
//- interpolate field on surface // Interpolate
//- Interpolate field on surface
virtual tmp<scalarField> interpolate virtual tmp<scalarField> interpolate
( (
const interpolation<scalar>& const interpolation<scalar>&
) const; ) const;
//- interpolate field on surface //- Interpolate field on surface
virtual tmp<vectorField> interpolate virtual tmp<vectorField> interpolate
( (
const interpolation<vector>& const interpolation<vector>&
) const; ) const;
//- interpolate field on surface //- Interpolate field on surface
virtual tmp<sphericalTensorField> interpolate virtual tmp<sphericalTensorField> interpolate
( (
const interpolation<sphericalTensor>& const interpolation<sphericalTensor>&
) const; ) const;
//- interpolate field on surface //- Interpolate field on surface
virtual tmp<symmTensorField> interpolate virtual tmp<symmTensorField> interpolate
( (
const interpolation<symmTensor>& const interpolation<symmTensor>&
) const; ) const;
//- interpolate field on surface //- Interpolate field on surface
virtual tmp<tensorField> interpolate virtual tmp<tensorField> interpolate
( (
const interpolation<tensor>& const interpolation<tensor>&
) const; ) const;
// Output
//- Write //- Write
virtual void print(Ostream&) const; virtual void print(Ostream&) const;
}; };