From 33d24875f742f73334f8eeee2d63c204585cd843 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 22 Aug 2012 09:58:18 +0100 Subject: [PATCH 01/13] ENH: LES turbulence - named k and epsilon fields returned by utililty functions --- .../LES/GenEddyVisc/GenEddyVisc.H | 20 ++++++++-- .../LES/GenSGSStress/GenSGSStress.H | 37 +++++++++++++++++-- .../LES/GenEddyVisc/GenEddyVisc.H | 18 ++++++++- .../LES/GenSGSStress/GenSGSStress.H | 35 ++++++++++++++++-- 4 files changed, 98 insertions(+), 12 deletions(-) diff --git a/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.H b/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.H index f11a06da9b..fb7558eec6 100644 --- a/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.H +++ b/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -51,7 +51,7 @@ namespace LESModels { /*---------------------------------------------------------------------------*\ - Class GenEddyVisc Declaration + Class GenEddyVisc Declaration \*---------------------------------------------------------------------------*/ class GenEddyVisc @@ -108,7 +108,21 @@ public: //- Return sub-grid disipation rate virtual tmp epsilon() const { - return ce_*k()*sqrt(k())/delta(); + return tmp + ( + new volScalarField + ( + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + ce_*k()*sqrt(k())/delta() + ) + ); } //- Return viscosity diff --git a/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.H b/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.H index 20309c3203..ce0da3763f 100644 --- a/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.H +++ b/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -52,7 +52,7 @@ namespace LESModels { /*---------------------------------------------------------------------------*\ - Class GenSGSStress Declaration + Class GenSGSStress Declaration \*---------------------------------------------------------------------------*/ class GenSGSStress @@ -109,14 +109,43 @@ public: //- Return the SGS turbulent kinetic energy virtual tmp k() const { - return 0.5*tr(B_); + return tmp + ( + new volScalarField + ( + IOobject + ( + "k", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + 0.5*tr(B_) + ) + ); } //- Return the SGS turbulent dissipation virtual tmp epsilon() const { const volScalarField K(k()); - return ce_*K*sqrt(K)/delta(); + + return tmp + ( + new volScalarField + ( + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + ce_*K*sqrt(K)/delta() + ) + ); } //- Return the SGS viscosity diff --git a/src/turbulenceModels/incompressible/LES/GenEddyVisc/GenEddyVisc.H b/src/turbulenceModels/incompressible/LES/GenEddyVisc/GenEddyVisc.H index 62c216ee3e..c40adc383b 100644 --- a/src/turbulenceModels/incompressible/LES/GenEddyVisc/GenEddyVisc.H +++ b/src/turbulenceModels/incompressible/LES/GenEddyVisc/GenEddyVisc.H @@ -51,7 +51,7 @@ namespace LESModels { /*---------------------------------------------------------------------------*\ - Class GenEddyVisc Declaration + Class GenEddyVisc Declaration \*---------------------------------------------------------------------------*/ class GenEddyVisc @@ -104,7 +104,21 @@ public: //- Return sub-grid disipation rate virtual tmp epsilon() const { - return ce_*k()*sqrt(k())/delta(); + return tmp + ( + new volScalarField + ( + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + ce_*k()*sqrt(k())/delta() + ) + ); } //- Return the SGS viscosity. diff --git a/src/turbulenceModels/incompressible/LES/GenSGSStress/GenSGSStress.H b/src/turbulenceModels/incompressible/LES/GenSGSStress/GenSGSStress.H index 0456d69a71..f7b6040f37 100644 --- a/src/turbulenceModels/incompressible/LES/GenSGSStress/GenSGSStress.H +++ b/src/turbulenceModels/incompressible/LES/GenSGSStress/GenSGSStress.H @@ -52,7 +52,7 @@ namespace LESModels { /*---------------------------------------------------------------------------*\ - Class GenSGSStress Declaration + Class GenSGSStress Declaration \*---------------------------------------------------------------------------*/ class GenSGSStress @@ -104,14 +104,43 @@ public: //- Return the SGS turbulent kinetic energy. virtual tmp k() const { - return 0.5*tr(B_); + return tmp + ( + new volScalarField + ( + IOobject + ( + "k", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + 0.5*tr(B_) + ) + ); } //- Return the SGS turbulent dissipation. virtual tmp epsilon() const { const volScalarField K(k()); - return ce_*K*sqrt(K)/delta(); + + return tmp + ( + new volScalarField + ( + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + ce_*K*sqrt(K)/delta() + ) + ); } //- Return the SGS viscosity. From 37fbafd411f3c047c1ea371ba4f88456ec2fd549 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 22 Aug 2012 12:30:17 +0100 Subject: [PATCH 02/13] ENH: Replaced hard-coded TMax by constantProperties TMax --- .../ReactingMultiphaseParcel/ReactingMultiphaseParcel.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C index 84942b0349..461ec5b285 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C @@ -636,7 +636,7 @@ void Foam::ReactingMultiphaseParcel::calcSurfaceReactions *(sum(dMassSRGas) + sum(dMassSRLiquid) + sum(dMassSRSolid)) ); - const scalar xsi = min(T/5000.0, 1.0); + const scalar xsi = min(T/td.cloud().constProps().TMax(), 1.0); const scalar coeff = (1.0 - xsi*xsi)*td.cloud().constProps().hRetentionCoeff(); From 96a5814b08e5717a3b9df9ad7f2fba8898a29045 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 13 Sep 2012 15:04:58 +0100 Subject: [PATCH 03/13] ENH: flange: rename to meshQualityDict --- .../mesh/cvMesh/flange/system/cvMeshDict | 6 +- .../cvMesh/flange/system/meshQualityControls | 76 ------------------- .../mesh/cvMesh/flange/system/meshQualityDict | 73 ++++++++++++++++++ .../cvMesh/flange/system/snappyHexMeshDict | 8 +- 4 files changed, 81 insertions(+), 82 deletions(-) delete mode 100644 tutorials/mesh/cvMesh/flange/system/meshQualityControls create mode 100644 tutorials/mesh/cvMesh/flange/system/meshQualityDict diff --git a/tutorials/mesh/cvMesh/flange/system/cvMeshDict b/tutorials/mesh/cvMesh/flange/system/cvMeshDict index cbd86c379d..e0dace7c28 100644 --- a/tutorials/mesh/cvMesh/flange/system/cvMeshDict +++ b/tutorials/mesh/cvMesh/flange/system/cvMeshDict @@ -217,7 +217,9 @@ polyMeshFiltering } -#include "meshQualityControls" - +meshQualityControls +{ + #include "meshQualityDict" +} // ************************************************************************* // diff --git a/tutorials/mesh/cvMesh/flange/system/meshQualityControls b/tutorials/mesh/cvMesh/flange/system/meshQualityControls deleted file mode 100644 index 09ebbb2458..0000000000 --- a/tutorials/mesh/cvMesh/flange/system/meshQualityControls +++ /dev/null @@ -1,76 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ - -FoamFile -{ - version 2.0; - format ascii; - - root ""; - case ""; - instance ""; - local ""; - - class dictionary; - object meshQualityControls; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -meshQualityControls -{ - //- Maximum non-orthogonality allowed. Set to 180 to disable. - maxNonOrtho 65; - - //- Max skewness allowed. Set to <0 to disable. - maxBoundarySkewness 50; - maxInternalSkewness 10; - - //- Max concaveness allowed. Is angle (in degrees) below which concavity - // is allowed. 0 is straight face, <0 would be convex face. - // Set to 180 to disable. - maxConcave 80; - - //- Minimum quality of the tet formed by the face-centre - // and variable base point minimum decomposition triangles and - // the cell centre. This has to be a positive number for tracking - // to work. Set to very negative number (e.g. -1E30) to - // disable. - // <0 = inside out tet, - // 0 = flat tet - // 1 = regular tet - minTetQuality 1e-30; - - //- Minimum pyramid volume. Is absolute volume of cell pyramid. - // Set to a sensible fraction of the smallest cell volume expected. - // Set to very negative number (e.g. -1E30) to disable. - minVol 0; - - //- Minimum face area. Set to <0 to disable. - minArea -1; - - //- Minimum face twist. Set to <-1 to disable. dot product of face normal - //- and face centre triangles normal - minTwist 0.001; - - //- minimum normalised cell determinant - //- 1 = hex, <= 0 = folded or flattened illegal cell - minDeterminant 0.001; - - //- minFaceWeight (0 -> 0.5) - minFaceWeight 0.02; - - //- minVolRatio (0 -> 1) - minVolRatio 0.01; - - //must be >0 for Fluent compatibility - minTriangleTwist -1; -} - - -// ************************************************************************* // diff --git a/tutorials/mesh/cvMesh/flange/system/meshQualityDict b/tutorials/mesh/cvMesh/flange/system/meshQualityDict new file mode 100644 index 0000000000..1b83e2bd87 --- /dev/null +++ b/tutorials/mesh/cvMesh/flange/system/meshQualityDict @@ -0,0 +1,73 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +FoamFile +{ + version 2.0; + format ascii; + + root ""; + case ""; + instance ""; + local ""; + + class dictionary; + object meshQualityDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +//- Maximum non-orthogonality allowed. Set to 180 to disable. +maxNonOrtho 65; + +//- Max skewness allowed. Set to <0 to disable. +maxBoundarySkewness 50; +maxInternalSkewness 10; + +//- Max concaveness allowed. Is angle (in degrees) below which concavity +// is allowed. 0 is straight face, <0 would be convex face. +// Set to 180 to disable. +maxConcave 80; + +//- Minimum quality of the tet formed by the face-centre +// and variable base point minimum decomposition triangles and +// the cell centre. This has to be a positive number for tracking +// to work. Set to very negative number (e.g. -1E30) to +// disable. +// <0 = inside out tet, +// 0 = flat tet +// 1 = regular tet +minTetQuality 1e-30; + +//- Minimum pyramid volume. Is absolute volume of cell pyramid. +// Set to a sensible fraction of the smallest cell volume expected. +// Set to very negative number (e.g. -1E30) to disable. +minVol 0; + +//- Minimum face area. Set to <0 to disable. +minArea -1; + +//- Minimum face twist. Set to <-1 to disable. dot product of face normal +//- and face centre triangles normal +minTwist 0.001; + +//- minimum normalised cell determinant +//- 1 = hex, <= 0 = folded or flattened illegal cell +minDeterminant 0.001; + +//- minFaceWeight (0 -> 0.5) +minFaceWeight 0.02; + +//- minVolRatio (0 -> 1) +minVolRatio 0.01; + +//must be >0 for Fluent compatibility +minTriangleTwist -1; + + +// ************************************************************************* // diff --git a/tutorials/mesh/cvMesh/flange/system/snappyHexMeshDict b/tutorials/mesh/cvMesh/flange/system/snappyHexMeshDict index 034e3c0e74..9da7fabcaf 100644 --- a/tutorials/mesh/cvMesh/flange/system/snappyHexMeshDict +++ b/tutorials/mesh/cvMesh/flange/system/snappyHexMeshDict @@ -278,12 +278,12 @@ addLayersControls -// Generic mesh quality settings. At any undoable phase these determine -// where to undo. -#include "meshQualityControls" - meshQualityControls { + // Generic mesh quality settings. At any undoable phase these determine + // where to undo. + #include "meshQualityDict" + //- Number of error distribution iterations nSmoothScale 4; //- amount to scale back displacement at error points From e07309eea3ee8ee86a3a8986aaf5957c25cd461a Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 14 Sep 2012 13:30:59 +0100 Subject: [PATCH 04/13] BUG: layering: disable mesh movement if extrusion disabled --- .../autoHexMeshDriver/autoLayerDriver.C | 89 ++++++++++- .../autoHexMeshDriver/autoLayerDriver.H | 14 +- .../autoHexMeshDriver/autoLayerDriverShrink.C | 139 +++++++++++++++--- .../autoHexMeshDriver/autoSnapDriver.C | 23 ++- .../autoHexMeshDriver/autoSnapDriverFeature.C | 70 +++++++++ .../layerParameters/layerParameters.C | 2 +- .../layerParameters/layerParameters.H | 4 + .../meshRefinementProblemCells.C | 13 +- 8 files changed, 316 insertions(+), 38 deletions(-) diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index abe3bc487c..26b4fb0187 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -48,6 +48,10 @@ Description #include "globalIndex.H" #include "DynamicField.H" #include "PatchTools.H" +#include "slipPointPatchFields.H" +#include "fixedValuePointPatchFields.H" +#include "calculatedPointPatchFields.H" +#include "cyclicSlipPointPatchFields.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -71,7 +75,7 @@ void Foam::autoLayerDriver::dumpDisplacement ) { OFstream dispStr(prefix + "_disp.obj"); - Info<< "Writing all displacements to " << dispStr.name() << nl << endl; + Info<< "Writing all displacements to " << dispStr.name() << endl; label vertI = 0; @@ -87,7 +91,7 @@ void Foam::autoLayerDriver::dumpDisplacement OFstream illStr(prefix + "_illegal.obj"); - Info<< "Writing invalid displacements to " << illStr.name() << nl << endl; + Info<< "Writing invalid displacements to " << illStr.name() << endl; vertI = 0; @@ -801,6 +805,81 @@ void Foam::autoLayerDriver::setNumLayers } +// Construct pointVectorField with correct boundary conditions for adding +// layers +Foam::tmp +Foam::autoLayerDriver::makeLayerDisplacementField +( + const pointMesh& pMesh, + const labelList& numLayers +) +{ + // Construct displacement field. + const pointBoundaryMesh& pointPatches = pMesh.boundary(); + + wordList patchFieldTypes + ( + pointPatches.size(), + slipPointPatchVectorField::typeName + ); + + forAll(numLayers, patchI) + { + // 0 layers: do not allow lslip so fixedValue 0 + // >0 layers: fixedValue which gets adapted + if (numLayers[patchI] >= 0) + { + patchFieldTypes[patchI] = fixedValuePointPatchVectorField::typeName; + } + } + + forAll(pointPatches, patchI) + { + if (isA(pointPatches[patchI])) + { + patchFieldTypes[patchI] = calculatedPointPatchVectorField::typeName; + } + else if (isA(pointPatches[patchI])) + { + patchFieldTypes[patchI] = cyclicSlipPointPatchVectorField::typeName; + } + } + + +//Pout<< "*** makeLayerDisplacementField : boundary conditions:" << endl; +//forAll(patchFieldTypes, patchI) +//{ +// Pout<< "\t" << patchI << " name:" << pointPatches[patchI].name() +// << " type:" << patchFieldTypes[patchI] +// << " nLayers:" << numLayers[patchI] +// << endl; +//} + + const polyMesh& mesh = pMesh(); + + // Note: time().timeName() instead of meshRefinement::timeName() since + // postprocessable field. + tmp tfld + ( + new pointVectorField + ( + IOobject + ( + "pointDisplacement", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + pMesh, + dimensionedVector("displacement", dimLength, vector::zero), + patchFieldTypes + ) + ); + return tfld; +} + + void Foam::autoLayerDriver::growNoExtrusion ( const indirectPrimitivePatch& pp, @@ -2392,10 +2471,10 @@ void Foam::autoLayerDriver::addLayers mesh, pp(), patchIDs, - meshRefinement::makeDisplacementField + makeLayerDisplacementField ( pointMesh::New(mesh), - patchIDs + layerParams.numLayers() ), motionDict ) @@ -3186,7 +3265,7 @@ void Foam::autoLayerDriver::doLayers // Merge coplanar boundary faces mergePatchFacesUndo(layerParams, motionDict); - // Per patch the number of layers (0 if no layer) + // Per patch the number of layers (-1 or 0 if no layer) const labelList& numLayers = layerParams.numLayers(); // Patches that need to get a layer diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H index cb720dc64f..d36d15a4cb 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H @@ -195,6 +195,19 @@ class autoLayerDriver List& extrudeStatus ) const; + //- Helper function to make a pointVectorField with correct + // bcs for layer addition: + // - numLayers > 0 : fixedValue + // - numLayers == 0 : fixedValue (always zero) + // - processor : calculated (so free to move) + // - cyclic/wedge/symmetry : slip + // - other : slip + static tmp makeLayerDisplacementField + ( + const pointMesh& pMesh, + const labelList& numLayers + ); + //- Grow no-extrusion layer. void growNoExtrusion ( @@ -444,7 +457,6 @@ class autoLayerDriver const PackedBoolList& isMasterEdge, const labelList& meshEdges, const scalar minCosLayerTermination, - scalarField& field, List& extrudeStatus, pointField& patchDisp, labelList& patchNLayers diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C index 35133f062d..58725470e1 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C @@ -99,6 +99,76 @@ void Foam::autoLayerDriver::sumWeights // Smooth field on moving patch +//void Foam::autoLayerDriver::smoothField +//( +// const motionSmoother& meshMover, +// const PackedBoolList& isMasterEdge, +// const labelList& meshEdges, +// const scalarField& fieldMin, +// const label nSmoothDisp, +// scalarField& field +//) const +//{ +// const indirectPrimitivePatch& pp = meshMover.patch(); +// const edgeList& edges = pp.edges(); +// const labelList& meshPoints = pp.meshPoints(); +// +// scalarField invSumWeight(pp.nPoints()); +// sumWeights +// ( +// isMasterEdge, +// meshEdges, +// meshPoints, +// edges, +// invSumWeight +// ); +// +// // Get smoothly varying patch field. +// Info<< "shrinkMeshDistance : Smoothing field ..." << endl; +// +// for (label iter = 0; iter < nSmoothDisp; iter++) +// { +// scalarField average(pp.nPoints()); +// averageNeighbours +// ( +// meshMover.mesh(), +// isMasterEdge, +// meshEdges, +// meshPoints, +// pp.edges(), +// invSumWeight, +// field, +// average +// ); +// +// // Transfer to field +// forAll(field, pointI) +// { +// //full smoothing neighbours + point value +// average[pointI] = 0.5*(field[pointI]+average[pointI]); +// +// // perform monotonic smoothing +// if +// ( +// average[pointI] < field[pointI] +// && average[pointI] >= fieldMin[pointI] +// ) +// { +// field[pointI] = average[pointI]; +// } +// } +// +// // Do residual calculation every so often. +// if ((iter % 10) == 0) +// { +// Info<< " Iteration " << iter << " residual " +// << gSum(mag(field-average)) +// /returnReduce(average.size(), sumOp