From c52c51e36774c9812ab59447090a678ab8ddc8fb Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Tue, 10 Apr 2018 21:18:16 +0100 Subject: [PATCH 1/4] Bugfix: cannot recalculate deltaCoeffs in a mesh after topo change due to zero volume/area elements. Move into movePoints --- src/finiteVolume/fvMesh/fvMesh.C | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index 928b3b83b..35090ec3f 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -556,11 +556,11 @@ void Foam::fvMesh::updateMesh(const mapPolyMesh& mpm) // This is a temporary solution surfaceInterpolation::movePoints(); - // Note: deltaCoeffs cannot be left on lazy evaluation on mesh motion - // because tangled comms will occur when they are accessed from - // individual boundary conditions + // Note: + // Not allowed to call deltaCoeffs here because the faces and cells may be + // at zero area/volume. It will be called in movePoints after the + // topo change. // HJ, VV and IG, 25/Oct/2016 - deltaCoeffs(); // Function object update moved to polyMesh // HJ, 29/Aug/2010 @@ -587,7 +587,6 @@ void Foam::fvMesh::syncUpdateMesh() // because tangled comms will occur when they are accessed from // individual boundary conditions // HJ, VV and IG, 25/Oct/2016 - deltaCoeffs(); // Function object update moved to polyMesh // HJ, 29/Aug/2010 From efcc2b1b7df8543c7873f89a6f50c30e047b1b11 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Thu, 12 Apr 2018 14:05:28 +0100 Subject: [PATCH 2/4] Robustness improvement for layer addition/removal triggering --- .../layerAdditionRemoval/addCellLayer.C | 4 +-- .../layerAdditionRemoval.C | 31 ++++++++++++++++--- .../layerAdditionRemoval.H | 19 ++++++------ 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/addCellLayer.C b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/addCellLayer.C index b1ea2c9b3..81dc957a9 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/addCellLayer.C +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/addCellLayer.C @@ -87,7 +87,7 @@ void Foam::layerAdditionRemoval::addCellLayer { extrusionDir[mpI] = points[ptc[mpI]] - points[mp[mpI]]; } - extrusionDir *= addDelta_*maxLayerThickness_; + extrusionDir *= addDelta_()*maxLayerThickness_; } else { @@ -118,7 +118,7 @@ void Foam::layerAdditionRemoval::addCellLayer polyAddPoint ( points[mp[pointI]] // point -// + addDelta_*maxLayerThickness_*extrusionDir[pointI], +// + addDelta_()*maxLayerThickness_*extrusionDir[pointI], + extrusionDir[pointI], mp[pointI], // master point -1, // zone for point diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.C b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.C index e15066faa..47443b8de 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.C +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.C @@ -48,8 +48,19 @@ namespace Foam } -const Foam::scalar Foam::layerAdditionRemoval::addDelta_ = 0.3; -const Foam::scalar Foam::layerAdditionRemoval::removeDelta_ = 0.1; +const Foam::debug::tolerancesSwitch +Foam::layerAdditionRemoval::motionDelta_ +( + "layerAdditionRemoval::motionDelta", + 0.01 +); + +const Foam::debug::tolerancesSwitch +Foam::layerAdditionRemoval::addDelta_ +( + "layerAdditionRemoval::addDelta", + 0.3 +); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -354,7 +365,12 @@ bool Foam::layerAdditionRemoval::changeTopology() const topologicalChange = false; } - else if (avgDelta < oldLayerThickness_) + // New criterion to avoid round-off triggering layer addition/removal + // HJ, 30/Mar/2018 + else if + ( + (oldLayerThickness_ - avgDelta) > motionDelta_()*minLayerThickness_ + ) { // Layers moving towards removal if (minDelta < minLayerThickness_) @@ -397,7 +413,12 @@ bool Foam::layerAdditionRemoval::changeTopology() const oldLayerThickness_ = avgDelta; } } - else + // New criterion to avoid round-off triggering layer addition/removal + // HJ, 30/Mar/2018 + else if + ( + (avgDelta - oldLayerThickness_) > motionDelta_()*minLayerThickness_ + ) { // Layers moving towards addition if (maxDelta > maxLayerThickness_) @@ -422,6 +443,8 @@ bool Foam::layerAdditionRemoval::changeTopology() const oldLayerThickness_ = avgDelta; } } + // else the motion change is smaller than the tolerance and the layer + // interface is practically static. HJ, 30/Mar/2018 return topologicalChange; } diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.H b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.H index c13c616fe..56497d60d 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.H +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.H @@ -40,6 +40,7 @@ SourceFiles #include "polyMeshModifier.H" #include "primitiveFacePatch.H" #include "ZoneIDs.H" +#include "tolerancesSwitch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -128,13 +129,14 @@ class layerAdditionRemoval // Static data members - //- Thickness insertion fraction for the pre-motion - static const scalar addDelta_; + //- Motion detection fraction: if the motion is smaller than + // motionDelta*minLayerThickness_, it is assumed that the mesh is + // not layering + static const debug::tolerancesSwitch motionDelta_; + + //- Thickness insertion fraction for the pre-motion + static const debug::tolerancesSwitch addDelta_; - //- Thickness removal fraction for the cell collapse - // Note: the cell will be collapsed to this relative - // thickness before the layer is removed. - static const scalar removeDelta_; public: @@ -166,9 +168,8 @@ public: ); - // Destructor - - virtual ~layerAdditionRemoval(); + //- Destructor + virtual ~layerAdditionRemoval(); // Member Functions From 268bb07d15d8d2de5df531f7702df54da05f15ad Mon Sep 17 00:00:00 2001 From: Dario Zivkovic Date: Sun, 28 Oct 2018 15:25:36 +0100 Subject: [PATCH 3/4] Bugfix: added mapping methods to point patch vector fields that have pointField 'p0_' member. --- ...llatingDisplacementPointPatchVectorField.C | 25 ++++++++++++++++++- ...llatingDisplacementPointPatchVectorField.H | 16 ++++++++++++ ...OscillatingVelocityPointPatchVectorField.C | 25 ++++++++++++++++++- ...OscillatingVelocityPointPatchVectorField.H | 16 ++++++++++++ ...oscillatingVelocityPointPatchVectorField.C | 25 ++++++++++++++++++- ...oscillatingVelocityPointPatchVectorField.H | 16 ++++++++++++ 6 files changed, 120 insertions(+), 3 deletions(-) diff --git a/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C b/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C index 540a5d836..3fd847bcd 100644 --- a/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C +++ b/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C @@ -99,7 +99,7 @@ angularOscillatingDisplacementPointPatchVectorField angle0_(ptf.angle0_), amplitude_(ptf.amplitude_), omega_(ptf.omega_), - p0_(ptf.p0_) + p0_(ptf.p0_, mapper) {} @@ -122,6 +122,29 @@ angularOscillatingDisplacementPointPatchVectorField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void angularOscillatingDisplacementPointPatchVectorField::autoMap +( + const PointPatchFieldMapper& m +) +{ + fixedValuePointPatchVectorField::autoMap(m); + p0_.autoMap(m); +} + +void angularOscillatingDisplacementPointPatchVectorField::rmap +( + const PointPatchField + & ptf, + const labelList& addr +) +{ + const angularOscillatingDisplacementPointPatchVectorField& aODptf = + refCast(ptf); + + fixedValuePointPatchVectorField::rmap(aODptf, addr); + p0_.rmap(aODptf.p0_, addr); +} + void angularOscillatingDisplacementPointPatchVectorField::updateCoeffs() { if (this->updated()) diff --git a/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.H b/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.H index 5e91e06b6..f40b0d6d1 100644 --- a/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.H +++ b/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.H @@ -138,6 +138,22 @@ public: // Member functions + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + void autoMap + ( + const PointPatchFieldMapper& + ); + + //- Reverse map the given pointPatchField onto this pointPatchField + void rmap + ( + const PointPatchField + &, + const labelList& + ); + // Evaluation functions //- Update the coefficients associated with the patch field diff --git a/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C b/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C index 0ba8a8711..82501c621 100644 --- a/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C +++ b/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C @@ -99,7 +99,7 @@ angularOscillatingVelocityPointPatchVectorField angle0_(ptf.angle0_), amplitude_(ptf.amplitude_), omega_(ptf.omega_), - p0_(ptf.p0_) + p0_(ptf.p0_, mapper) {} @@ -122,6 +122,29 @@ angularOscillatingVelocityPointPatchVectorField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void angularOscillatingVelocityPointPatchVectorField::autoMap +( + const PointPatchFieldMapper& m +) +{ + fixedValuePointPatchVectorField::autoMap(m); + p0_.autoMap(m); +} + +void angularOscillatingVelocityPointPatchVectorField::rmap +( + const PointPatchField + & ptf, + const labelList& addr +) +{ + const angularOscillatingVelocityPointPatchVectorField& aOVptf = + refCast(ptf); + + fixedValuePointPatchVectorField::rmap(aOVptf, addr); + p0_.rmap(aOVptf.p0_, addr); +} + void angularOscillatingVelocityPointPatchVectorField::updateCoeffs() { if (this->updated()) diff --git a/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.H b/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.H index 8c7054614..eae094f9c 100644 --- a/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.H +++ b/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.H @@ -130,6 +130,22 @@ public: // Member functions + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + void autoMap + ( + const PointPatchFieldMapper& + ); + + //- Reverse map the given pointPatchField onto this pointPatchField + void rmap + ( + const PointPatchField + &, + const labelList& + ); + // Evaluation functions //- Update the coefficients associated with the patch field diff --git a/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C b/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C index aa0fa36d6..b7d5d03e3 100644 --- a/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C +++ b/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C @@ -90,7 +90,7 @@ oscillatingVelocityPointPatchVectorField fixedValuePointPatchVectorField(ptf, p, iF, mapper), amplitude_(ptf.amplitude_), omega_(ptf.omega_), - p0_(ptf.p0_) + p0_(ptf.p0_, mapper) {} @@ -110,6 +110,29 @@ oscillatingVelocityPointPatchVectorField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void oscillatingVelocityPointPatchVectorField::autoMap +( + const PointPatchFieldMapper& m +) +{ + fixedValuePointPatchVectorField::autoMap(m); + p0_.autoMap(m); +} + +void oscillatingVelocityPointPatchVectorField::rmap +( + const PointPatchField + & ptf, + const labelList& addr +) +{ + const oscillatingVelocityPointPatchVectorField& oVptf = + refCast(ptf); + + fixedValuePointPatchVectorField::rmap(oVptf, addr); + p0_.rmap(oVptf.p0_, addr); +} + void oscillatingVelocityPointPatchVectorField::updateCoeffs() { if (this->updated()) diff --git a/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.H b/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.H index 3dc0be99a..6cd44e071 100644 --- a/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.H +++ b/src/dynamicMesh/meshMotion/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.H @@ -128,6 +128,22 @@ public: // Member functions + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + void autoMap + ( + const PointPatchFieldMapper& + ); + + //- Reverse map the given pointPatchField onto this pointPatchField + void rmap + ( + const PointPatchField + &, + const labelList& + ); + // Evaluation functions //- Update the coefficients associated with the patch field From caf4a225eb3810f87cb0659275a20df893aab259 Mon Sep 17 00:00:00 2001 From: Dario Zivkovic Date: Mon, 24 Dec 2018 14:49:22 +0100 Subject: [PATCH 4/4] Make sixDoF's rmap override PointPatchFieldTemplate base class method --- .../sixDoFRigidBodyDisplacementPointPatchVectorField.C | 3 ++- .../sixDoFRigidBodyDisplacementPointPatchVectorField.H | 3 ++- ...uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C | 3 ++- ...uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C index 5ee6f8cd0..8ce66362c 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C @@ -126,7 +126,8 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::autoMap void sixDoFRigidBodyDisplacementPointPatchVectorField::rmap ( - const pointPatchField& ptf, + const PointPatchField + & ptf, const labelList& addr ) { diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.H index 1d8ca4d78..d6503052b 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.H +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.H @@ -152,7 +152,8 @@ public: //- Reverse map the given pointPatchField onto this pointPatchField virtual void rmap ( - const pointPatchField&, + const PointPatchField + &, const labelList& ); diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C index 9df7a120d..dbee07a2a 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C @@ -125,7 +125,8 @@ void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::autoMap void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::rmap ( - const pointPatchField& ptf, + const PointPatchField + & ptf, const labelList& addr ) { diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H index 0a5f350ee..a17a46198 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H @@ -153,7 +153,8 @@ public: //- Reverse map the given pointPatchField onto this pointPatchField virtual void rmap ( - const pointPatchField&, + const PointPatchField + &, const labelList& );