From 55aa8c272acf998b96f70fde14e63bf906b0f79e Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Thu, 17 May 2018 14:52:46 +0100 Subject: [PATCH] Updates for dynamic refinement and immersed boundary --- .../dynamicPolyRefinementFvMesh.C | 5 +- .../dynamicPolyRefinementFvMesh.H | 11 ++++- ...undaryDynamicRefineSolidBodyMotionFvMesh.C | 23 +++------ .../immersedBoundaryRefinement.C | 2 +- .../constant/dynamicMeshDict | 48 +++---------------- 5 files changed, 26 insertions(+), 63 deletions(-) diff --git a/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.C b/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.C index ec07edfd3..45b236621 100644 --- a/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.C +++ b/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.C @@ -82,7 +82,8 @@ void Foam::dynamicPolyRefinementFvMesh::readDict() Foam::dynamicPolyRefinementFvMesh::dynamicPolyRefinementFvMesh ( - const IOobject& io + const IOobject& io, + const word subDictName ) : topoChangerFvMesh(io), @@ -99,7 +100,7 @@ Foam::dynamicPolyRefinementFvMesh::dynamicPolyRefinementFvMesh IOobject::NO_WRITE, false ) - ).subDict(typeName + "Coeffs") + ).subDict(subDictName + "Coeffs") ), refineInterval_(readLabel(refinementDict_.lookup("refineInterval"))), unrefineInterval_(readLabel(refinementDict_.lookup("unrefineInterval"))), diff --git a/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.H b/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.H index fe06f4691..c52c69bb7 100644 --- a/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.H +++ b/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.H @@ -106,8 +106,15 @@ public: // Constructors - //- Construct from IOobject - explicit dynamicPolyRefinementFvMesh(const IOobject& io); + //- Construct from IOobject and optional name for the subdictionary + // containing the refinement (and possibly other controls). The second + // parameter is useful if we derive another dynamic mesh class from + // this one instead of topoChangerFvMesh base class. VV, 17/May/2018. + dynamicPolyRefinementFvMesh + ( + const IOobject& io, + const word subDictName = typeName + ); //- Destructor diff --git a/src/immersedBoundary/immersedBoundaryDynamicMesh/immersedBoundaryDynamicRefineSolidBodyMotionFvMesh/immersedBoundaryDynamicRefineSolidBodyMotionFvMesh.C b/src/immersedBoundary/immersedBoundaryDynamicMesh/immersedBoundaryDynamicRefineSolidBodyMotionFvMesh/immersedBoundaryDynamicRefineSolidBodyMotionFvMesh.C index 113d83022..098927fd6 100644 --- a/src/immersedBoundary/immersedBoundaryDynamicMesh/immersedBoundaryDynamicRefineSolidBodyMotionFvMesh/immersedBoundaryDynamicRefineSolidBodyMotionFvMesh.C +++ b/src/immersedBoundary/immersedBoundaryDynamicMesh/immersedBoundaryDynamicRefineSolidBodyMotionFvMesh/immersedBoundaryDynamicRefineSolidBodyMotionFvMesh.C @@ -60,25 +60,14 @@ addToRunTimeSelectionTable Foam::immersedBoundaryDynamicRefineSolidBodyMotionFvMesh:: immersedBoundaryDynamicRefineSolidBodyMotionFvMesh(const IOobject& io) : - dynamicPolyRefinementFvMesh(io), + // Create base class with the name of this class to be able to define all + // the controls in immersedBoundaryDynamicRefineSolidBodyMotionFvMeshCoeffs + // subdictionary in dynamicMeshDict (see dynamicPolyRefinementFvMesh + // constructor). VV, 17/May/2018. + dynamicPolyRefinementFvMesh(io, typeName), ibMotions_() { - // Read motion function for all regions - dictionary dynamicMeshCoeffs - ( - IOdictionary - ( - IOobject - ( - "dynamicMeshDict", - time().constant(), - *this, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ).subDict(typeName + "Coeffs") - ); - + // Read Immersed Boundary motion functions from base class dictionary PtrList motionDicts(refinementDict().lookup("motionFunctions")); ibMotions_.setSize(motionDicts.size()); diff --git a/src/immersedBoundary/immersedBoundaryDynamicMesh/immersedBoundaryRefinement/immersedBoundaryRefinement.C b/src/immersedBoundary/immersedBoundaryDynamicMesh/immersedBoundaryRefinement/immersedBoundaryRefinement.C index 04c5a55ab..a9a86c1eb 100644 --- a/src/immersedBoundary/immersedBoundaryDynamicMesh/immersedBoundaryRefinement/immersedBoundaryRefinement.C +++ b/src/immersedBoundary/immersedBoundaryDynamicMesh/immersedBoundaryRefinement/immersedBoundaryRefinement.C @@ -197,7 +197,7 @@ Foam::immersedBoundaryRefinement::unrefinementPointCandidates() const if ( pointDistance[pointI] < -unrefinementDistance_ - || pointDistance[pointI] > unrefinementDistance_ + || pointDistance[pointI] > SMALL ) { unrefinementCandidates.append(pointI); diff --git a/tutorials/immersedBoundary/refiningMovingCylinderInChannelIco/constant/dynamicMeshDict b/tutorials/immersedBoundary/refiningMovingCylinderInChannelIco/constant/dynamicMeshDict index 0ef19fd2a..391c9624b 100644 --- a/tutorials/immersedBoundary/refiningMovingCylinderInChannelIco/constant/dynamicMeshDict +++ b/tutorials/immersedBoundary/refiningMovingCylinderInChannelIco/constant/dynamicMeshDict @@ -18,25 +18,10 @@ FoamFile // dynamicFvMesh immersedBoundarySolidBodyMotionFvMesh; dynamicFvMesh immersedBoundaryDynamicRefineSolidBodyMotionFvMesh; -immersedBoundarySolidBodyMotionFvMeshCoeffs -{ - motionFunctions - ( - ibCylinder - { - solidBodyMotionFunction linearOscillation; - linearOscillationCoeffs - { - amplitude (0.5 0 0); - period 2.5; - } - } - ); -} - immersedBoundaryDynamicRefineSolidBodyMotionFvMeshCoeffs { + // Immersed boundary controls motionFunctions ( ibCylinder @@ -49,18 +34,14 @@ immersedBoundaryDynamicRefineSolidBodyMotionFvMeshCoeffs } } ); -} - -dynamicPolyRefinementFvMeshCoeffs -{ // Dynamic mesh procedure controls // Refine every refineInterval step - refineInterval 1; + refineInterval 2; // Unrefine every unrefineInterval step - unrefineInterval 1; + unrefineInterval 2; // Separate refinement/unrefinement steps. In case this is switched on, // if both refinement and unrefinement should have been performed in a @@ -72,8 +53,8 @@ dynamicPolyRefinementFvMeshCoeffs refinementSelection { type immersedBoundaryRefinement; - refinementDistance 0.1; - coarseningDistance 0.1; + refinementDistance 0.08; + unrefinementDistance 0.08; } // Polyhedral refinement engine controls @@ -86,31 +67,16 @@ dynamicPolyRefinementFvMeshCoeffs maxRefinementLevel 2; // Number of buffer layers between refinement levels - nRefinementBufferLayers 0; + nRefinementBufferLayers 1; // Number of buffer layers for unrefinement in order to run away from the // region that is getting refined at the same time in order to avoid point // level inconsistencies - nUnrefinementBufferLayers 2; + nUnrefinementBufferLayers 3; // Whether to use edge based consistency check. Needed when one allows more // than 2 refinement levels (automatically switched on) edgeBasedConsistency true; - - // Motion functions for IBM - motionFunctions - ( - ibCylinder - { - solidBodyMotionFunction linearOscillation; - linearOscillationCoeffs - { - amplitude (0.5 0 0); - period 2.5; - } - } - ); } - // ************************************************************************* //