diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index e8c2915f13..beba23a4da 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -58,6 +58,7 @@ Description #include "globalIndex.H" #include "IOmanip.H" #include "decompositionModel.H" +#include "fvMeshTools.H" using namespace Foam; @@ -813,6 +814,7 @@ int main(int argc, char *argv[]) readScalar(meshDict.lookup("mergeTolerance")) ); + const Switch keepPatches(meshDict.lookupOrDefault("keepPatches", false)); // Read decomposePar dictionary @@ -1517,6 +1519,12 @@ int main(int argc, char *argv[]) motionDict ); + // Remove zero sized patches originating from faceZones + if (!keepPatches && !wantSnap && !wantLayers) + { + fvMeshTools::removeEmptyPatches(mesh, true); + } + writeMesh ( "Refined mesh", @@ -1559,6 +1567,12 @@ int main(int argc, char *argv[]) snapParams ); + // Remove zero sized patches originating from faceZones + if (!keepPatches && !wantLayers) + { + fvMeshTools::removeEmptyPatches(mesh, true); + } + writeMesh ( "Snapped mesh", @@ -1609,6 +1623,12 @@ int main(int argc, char *argv[]) distributor ); + // Remove zero sized patches originating from faceZones + if (!keepPatches) + { + fvMeshTools::removeEmptyPatches(mesh, true); + } + writeMesh ( "Layer mesh", @@ -1622,6 +1642,7 @@ int main(int argc, char *argv[]) } + { // Check final mesh Info<< "Checking final mesh ..." << endl; diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index 5a8508d151..506a68786b 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict @@ -296,8 +296,18 @@ castellatedMeshControls locationInMesh (5 0.28 0.43); // Whether any faceZones (as specified in the refinementSurfaces) - // are only on the boundary of corresponding cellZones or also allow - // free-standing zone faces. Not used if there are no faceZones. + // are only on the boundary of corresponding cellZones. + // Not used if there are no faceZones. The behaviour has changed + // with respect to previous versions: + // true : all intersections with surface are put in faceZone + // (same behaviour as before) + // false : depending on the type of surface intersected: + // - if intersecting surface has faceZone only (so no cellZone) + // leave in faceZone (so behave as if set to true) (= changed + // behaviour) + // - if intersecting surface has faceZone and cellZone + // remove if inbetween same cellZone or if on boundary + // (same behaviour as before) allowFreeStandingZoneFaces true; diff --git a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C index 6882b0f7ee..15198df7e1 100644 --- a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C +++ b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C @@ -290,6 +290,8 @@ void calc mesh ); + #include "createFvOptions.H" + if (phi.dimensions() == dimVolume/dimTime) { IOobject turbulencePropertiesHeader diff --git a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C index 449eb03e15..ef36104006 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C +++ b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C @@ -62,7 +62,12 @@ tmp kOmegaSSTDES::dTilda const volScalarField& k = this->k_; const volScalarField& omega = this->omega_; - return min(CDES*this->delta(), sqrt(k)/(this->betaStar_*omega)); + return + min + ( + CDES*this->delta(), + sqrt(k + this->kMin_)/(this->betaStar_*omega) + ); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C b/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C index 81212cb410..83d156be08 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C @@ -284,6 +284,17 @@ void realizableKE::correct() // Update epsilon and G at the wall epsilon_.boundaryField().updateCoeffs(); + // SAF: limiting thermo->nu(). If psiThermo is used rho might be < 0 + // temporarily when p < 0 then nu < 0 which needs limiting + volScalarField nuLimited + ( + max + ( + this->nu(), + dimensionedScalar("zero", this->nu()().dimensions(), 0.0) + ) + ); + // Dissipation equation tmp epsEqn ( @@ -294,7 +305,7 @@ void realizableKE::correct() C1*alpha*rho*magS*epsilon_ - fvm::Sp ( - C2_*alpha*rho*epsilon_/(k_ + sqrt(this->nu()*epsilon_)), + C2_*alpha*rho*epsilon_/(k_ + sqrt(nuLimited*epsilon_)), epsilon_ ) + epsilonSource() diff --git a/src/TurbulenceModels/turbulenceModels/RAS/v2f/v2f.C b/src/TurbulenceModels/turbulenceModels/RAS/v2f/v2f.C index 4a76ee1870..6226b6851d 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/v2f/v2f.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/v2f/v2f.C @@ -38,16 +38,47 @@ namespace RASModels template tmp v2f::Ts() const { - return max(k_/epsilon_, 6.0*sqrt(this->nu()/epsilon_)); + // SAF: limiting thermo->nu(). If psiThermo is used rho might be < 0 + // temporarily when p < 0 then nu < 0 which needs limiting + return + max + ( + k_/epsilon_, + 6.0*sqrt + ( + max + ( + this->nu(), + dimensionedScalar("zero", this->nu()().dimensions(), 0.0) + ) + / epsilon_ + ) + ); } template tmp v2f::Ls() const { + // SAF: limiting thermo->nu(). If psiThermo is used rho might be < 0 + // temporarily when p < 0 then nu < 0 which needs limiting return - CL_*max(pow(k_, 1.5) - /epsilon_, Ceta_*pow025(pow3(this->nu())/epsilon_)); + CL_ + * max + ( + pow(k_, 1.5)/epsilon_, + Ceta_*pow025 + ( + pow3 + ( + max + ( + this->nu(), + dimensionedScalar("zero", this->nu()().dimensions(), 0.0) + ) + )/epsilon_ + ) + ); } diff --git a/src/dynamicMesh/fvMeshTools/fvMeshTools.C b/src/dynamicMesh/fvMeshTools/fvMeshTools.C index ecbe00325d..df8aaccdb4 100644 --- a/src/dynamicMesh/fvMeshTools/fvMeshTools.C +++ b/src/dynamicMesh/fvMeshTools/fvMeshTools.C @@ -355,6 +355,69 @@ void Foam::fvMeshTools::reorderPatches } +Foam::labelList Foam::fvMeshTools::removeEmptyPatches +( + fvMesh& mesh, + const bool validBoundary +) +{ + const polyBoundaryMesh& pbm = mesh.boundaryMesh(); + + labelList newToOld(pbm.size()); + labelList oldToNew(pbm.size(), -1); + label newI = 0; + + + // Assumes all non-coupled boundaries are on all processors! + forAll(pbm, patchI) + { + const polyPatch& pp = pbm[patchI]; + + if (!isA(pp)) + { + label nFaces = pp.size(); + if (validBoundary) + { + reduce(nFaces, sumOp