From e67f8d0929acc2a3113e345f052087280dccb2f9 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 9 Nov 2023 09:15:12 +0000 Subject: [PATCH] TUT: overset: demo some motion. See #2711. --- .../cellCellStencil/cellCellStencil.C | 27 +++++++++++ .../cellCellStencil/cellCellStencil.H | 6 ++- .../cellVolumeWeightCellCellStencil.C | 12 +---- .../inverseDistanceCellCellStencil.C | 15 ++---- .../overPimpleDyMFoam/cylinder/README.txt | 7 ++- .../0.orig/cellDisplacement | 47 +++++++++++++++++++ .../0.orig/pointDisplacement | 13 ++++- 7 files changed, 101 insertions(+), 26 deletions(-) create mode 100644 tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/cellDisplacement diff --git a/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C index 2d6ddbcb30..58104fca9d 100644 --- a/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C +++ b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C @@ -110,6 +110,33 @@ Foam::word Foam::cellCellStencil::baseName(const word& name) } +void Foam::cellCellStencil::suppressMotionFields() +{ + // Protect local fields from interpolation + nonInterpolatedFields_.insert("cellInterpolationWeight"); + nonInterpolatedFields_.insert("cellTypes"); + nonInterpolatedFields_.insert("maxMagWeight"); + + // For convenience also suppress frequently used displacement field + { + nonInterpolatedFields_.insert("cellDisplacement"); + nonInterpolatedFields_.insert("grad(cellDisplacement)"); + const word w("snGradCorr(cellDisplacement)"); + const word d("((viscosity*faceDiffusivity)*magSf)"); + nonInterpolatedFields_.insert("surfaceIntegrate(("+d+"*"+w+"))"); + } + + // For convenience also suppress frequently used displacement field + { + nonInterpolatedFields_.insert("cellMotionU"); + nonInterpolatedFields_.insert("grad(cellMotionU)"); + const word w("snGradCorr(cellMotionU)"); + const word d("((viscosity*faceDiffusivity)*magSf)"); + nonInterpolatedFields_.insert("surfaceIntegrate(("+d+"*"+w+"))"); + } +} + + const Foam::labelIOList& Foam::cellCellStencil::zoneID(const fvMesh& mesh) { labelIOList* zoneIDPtr = mesh.getObjectPtr("zoneID"); diff --git a/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.H b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.H index 8191a3df72..72541623ca 100644 --- a/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.H +++ b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2022 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -117,6 +117,10 @@ protected: //- Helper: strip off trailing _0 static word baseName(const word& name); + //- Helper: populate nonInterpolatedFields_ with motion solver + // fields + void suppressMotionFields(); + private: diff --git a/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C b/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C index 4a8026fbcf..fd04966eff 100644 --- a/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C +++ b/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C @@ -541,16 +541,8 @@ Foam::cellCellStencils::cellVolumeWeight::cellVolumeWeight dict.getOrDefault("allowInterpolatedDonors", true) ) { - // Protect local fields from interpolation - nonInterpolatedFields_.insert("cellTypes"); - nonInterpolatedFields_.insert("cellInterpolationWeight"); - - // For convenience also suppress frequently used displacement field - nonInterpolatedFields_.insert("cellDisplacement"); - nonInterpolatedFields_.insert("grad(cellDisplacement)"); - const word w("snGradCorr(cellDisplacement)"); - const word d("((viscosity*faceDiffusivity)*magSf)"); - nonInterpolatedFields_.insert("surfaceIntegrate(("+d+"*"+w+"))"); + // Add motion-solver fields to non-interpolated fields + suppressMotionFields(); // Read zoneID this->zoneID(); diff --git a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C index a0fa676559..b0e999c0f8 100644 --- a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C +++ b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2022 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -1739,17 +1739,8 @@ Foam::cellCellStencils::inverseDistance::inverseDistance fvPatchFieldBase::zeroGradientType() ) { - // Protect local fields from interpolation - nonInterpolatedFields_.insert("cellInterpolationWeight"); - nonInterpolatedFields_.insert("cellTypes"); - nonInterpolatedFields_.insert("maxMagWeight"); - - // For convenience also suppress frequently used displacement field - nonInterpolatedFields_.insert("cellDisplacement"); - nonInterpolatedFields_.insert("grad(cellDisplacement)"); - const word w("snGradCorr(cellDisplacement)"); - const word d("((viscosity*faceDiffusivity)*magSf)"); - nonInterpolatedFields_.insert("surfaceIntegrate(("+d+"*"+w+"))"); + // Add motion-solver fields to non-interpolated fields + suppressMotionFields(); // Read zoneID this->zoneID(); diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/README.txt b/tutorials/incompressible/overPimpleDyMFoam/cylinder/README.txt index 172ae4285f..79957c39a0 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/README.txt +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/README.txt @@ -1,8 +1,11 @@ -Transient, steady mesh ------------------------ +Transient, moving mesh +---------------------- cylinderMesh/ For generating (2D) mesh cylinder mesh cylinderAndBackground/ BlockMesh for background and running + + 0.orig/pointDisplacement set up to use table driven motion. Set bc of + walls to e.g. uniformValue (0 0 0) to have steady mesh. diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/cellDisplacement b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/cellDisplacement new file mode 100644 index 0000000000..4dd548d7ac --- /dev/null +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/cellDisplacement @@ -0,0 +1,47 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2306 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object cellDisplacement; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 0 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + overset + { + patchType overset; + type zeroGradient; + } + + // Cylinder wall + walls + { + type cellMotion; + value $internalField; + } + + // Outside patches + ".*" + { + type cellMotion; + value $internalField; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/pointDisplacement b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/pointDisplacement index df73743166..2155179757 100644 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/pointDisplacement +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/pointDisplacement @@ -20,18 +20,29 @@ internalField uniform (0 0 0); boundaryField { + #includeEtc "caseDicts/setConstraintTypes" + overset { patchType overset; type zeroGradient; } + // Cylinder wall walls { type uniformFixedValue; - uniformValue (0 0 0); + uniformValue table + ( + (0 (0 0 0)) + (0.5 (0 0 1)) + (1 (0 0 0)) + (1.5 (0 0 -1)) + (2 (0 0 0)) + ); } + // Outside patches ".*" { type uniformFixedValue;