From bbb20771605c52d9c8007259ad0c50ed0f728ddb Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 11 Apr 2013 15:04:39 +0100 Subject: [PATCH 1/9] ENH: searhcableSurfacetoFaceZone: allow triSurfaceMesh specification --- .../mesh/manipulation/createBaffles/createBafflesDict | 2 ++ .../faceSelection/searchableSurfaceSelection.C | 11 ++++++++++- .../utilities/mesh/manipulation/topoSet/topoSetDict | 1 + .../searchableSurfaceToFaceZone.C | 10 +++++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/applications/utilities/mesh/manipulation/createBaffles/createBafflesDict b/applications/utilities/mesh/manipulation/createBaffles/createBafflesDict index 99c03b4cfc..b392f07642 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/createBafflesDict +++ b/applications/utilities/mesh/manipulation/createBaffles/createBafflesDict @@ -138,6 +138,8 @@ baffles //- Select faces and orientation through a searchableSurface type searchableSurface; surface searchablePlate; + //name sphere.stl; // name if surface=triSurfaceMesh + origin (0.099 -0.006 0.004); span (0 0.012 0.012); diff --git a/applications/utilities/mesh/manipulation/createBaffles/faceSelection/searchableSurfaceSelection.C b/applications/utilities/mesh/manipulation/createBaffles/faceSelection/searchableSurfaceSelection.C index 04dbe07929..e7439d52f6 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/faceSelection/searchableSurfaceSelection.C +++ b/applications/utilities/mesh/manipulation/createBaffles/faceSelection/searchableSurfaceSelection.C @@ -28,6 +28,7 @@ License #include "syncTools.H" #include "searchableSurface.H" #include "fvMesh.H" +#include "Time.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -61,7 +62,15 @@ Foam::faceSelections::searchableSurfaceSelection::searchableSurfaceSelection searchableSurface::New ( word(dict.lookup("surface")), - mesh.objectRegistry::db(), + IOobject + ( + dict.lookupOrDefault("name", mesh.objectRegistry::db().name()), + mesh.time().constant(), + "triSurface", + mesh.objectRegistry::db(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ), dict ) ) diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSetDict b/applications/utilities/mesh/manipulation/topoSet/topoSetDict index 57514a2053..11dccf942b 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSetDict +++ b/applications/utilities/mesh/manipulation/topoSet/topoSetDict @@ -378,6 +378,7 @@ FoamFile // surface searchableSphere; // centre (0.05 0.05 0.005); // radius 0.025; +// //name sphere.stl; // Optional name if surface triSurfaceMesh // } // } // diff --git a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C index 039e14555f..d19f41fd77 100644 --- a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C @@ -69,7 +69,15 @@ Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone searchableSurface::New ( word(dict.lookup("surface")), - mesh.objectRegistry::db(), + IOobject + ( + dict.lookupOrDefault("name", mesh.objectRegistry::db().name()), + mesh.time().constant(), + "triSurface", + mesh.objectRegistry::db(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ) dict ) ) From 03cc5d1a72c08a9f532798bf275eed809c3d17b4 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 11 Apr 2013 15:09:33 +0100 Subject: [PATCH 2/9] COMP: searchableSurfaceToFaceZone: missing comma --- .../searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C index d19f41fd77..c9ce92f25b 100644 --- a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C @@ -28,6 +28,7 @@ License #include "faceZoneSet.H" #include "searchableSurface.H" #include "syncTools.H" +#include "Time.H" #include "addToRunTimeSelectionTable.H" @@ -77,7 +78,7 @@ Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone mesh.objectRegistry::db(), IOobject::MUST_READ, IOobject::NO_WRITE - ) + ), dict ) ) From e2e20fe87eb0a6f2060f1469121a7181f250947b Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 11 Apr 2013 15:11:15 +0100 Subject: [PATCH 3/9] STYLE:pressureInletOutletVe: typo --- .../pressureInletOutletVelocityFvPatchVectorField.H | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.H index 1ed301b191..49ebb5d77e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,7 +29,7 @@ Group Description This velocity inlet/outlet boundary condition is applied to pressure - boundaries where the pressure is specified. A zero-gradient condtion is + boundaries where the pressure is specified. A zero-gradient condition is applied for outflow (as defined by the flux); for inflow, the velocity is obtained from the patch-face normal component of the internal-cell value. From 2514121d78e5903706e1cc20c13144600bc34ce8 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 11 Apr 2013 15:12:29 +0100 Subject: [PATCH 4/9] STYLE: mappedPatchFieldBase: added comment --- .../derived/mappedField/mappedPatchFieldBase.H | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.H b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.H index 5072841094..22a3872eff 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.H @@ -25,7 +25,18 @@ Class Foam::mappedPatchFieldBase Description - Functionality for sampling fields using mappedPatchBase. + Functionality for sampling fields using mappedPatchBase. Every call to + mappedField() returns a sampled field, optionally scaled to maintain an + area-weighted average. + + Example usage: + + { + fieldName T; // default is same as fvPatchField + setAverage false; + average 1.0; // only if setAverage=true + interpolationScheme cellPoint; // default is cell + } SourceFiles mappedPatchFieldBase.C From e5e100abd30ff16afeaee9174fcb3d81419b2a22 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 11 Apr 2013 15:13:54 +0100 Subject: [PATCH 5/9] ENH: motionSmoother: split off patch consistency --- .../motionSmoother/motionSmoother.C | 64 +++++++++++-------- .../motionSmoother/motionSmoother.H | 4 ++ 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.C b/src/dynamicMesh/motionSmoother/motionSmoother.C index c7d5d28e76..dad3ea5977 100644 --- a/src/dynamicMesh/motionSmoother/motionSmoother.C +++ b/src/dynamicMesh/motionSmoother/motionSmoother.C @@ -678,34 +678,8 @@ void Foam::motionSmoother::correct() } -void Foam::motionSmoother::setDisplacement(pointField& patchDisp) +void Foam::motionSmoother::setDisplacementPatchFields() { - // See comment in .H file about shared points. - const polyBoundaryMesh& patches = mesh_.boundaryMesh(); - - forAll(patches, patchI) - { - const polyPatch& pp = patches[patchI]; - - if (pp.coupled()) - { - const labelList& meshPoints = pp.meshPoints(); - - forAll(meshPoints, i) - { - displacement_[meshPoints[i]] = vector::zero; - } - } - } - - const labelList& ppMeshPoints = pp_.meshPoints(); - - // Set internal point data from displacement on combined patch points. - forAll(ppMeshPoints, patchPointI) - { - displacement_[ppMeshPoints[patchPointI]] = patchDisp[patchPointI]; - } - // Adapt the fixedValue bc's (i.e. copy internal point data to // boundaryField for all affected patches) forAll(adaptPatchIDs_, i) @@ -765,6 +739,42 @@ void Foam::motionSmoother::setDisplacement(pointField& patchDisp) displacement_.boundaryField()[patchI] == displacement_.boundaryField()[patchI].patchInternalField(); } +} + + +void Foam::motionSmoother::setDisplacement(pointField& patchDisp) +{ + // See comment in .H file about shared points. + const polyBoundaryMesh& patches = mesh_.boundaryMesh(); + + forAll(patches, patchI) + { + const polyPatch& pp = patches[patchI]; + + if (pp.coupled()) + { + const labelList& meshPoints = pp.meshPoints(); + + forAll(meshPoints, i) + { + displacement_[meshPoints[i]] = vector::zero; + } + } + } + + const labelList& ppMeshPoints = pp_.meshPoints(); + + // Set internal point data from displacement on combined patch points. + forAll(ppMeshPoints, patchPointI) + { + displacement_[ppMeshPoints[patchPointI]] = patchDisp[patchPointI]; + } + + + // Adapt the fixedValue bc's (i.e. copy internal point data to + // boundaryField for all affected patches) + setDisplacementPatchFields(); + if (debug) { diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.H b/src/dynamicMesh/motionSmoother/motionSmoother.H index ee5432ad4e..fff07c4b94 100644 --- a/src/dynamicMesh/motionSmoother/motionSmoother.H +++ b/src/dynamicMesh/motionSmoother/motionSmoother.H @@ -385,6 +385,10 @@ public: //- Take over existing mesh position. void correct(); + //- Set patch fields on displacement to be consistent with + // internal values. + void setDisplacementPatchFields(); + //- Set displacement field from displacement on patch points. // Modify provided displacement to be consistent with actual // boundary conditions on displacement. Note: resets the From 1cf850f1644881510ed028436807f9358b10be79 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 11 Apr 2013 15:16:06 +0100 Subject: [PATCH 6/9] ENH: snappyHexMesh: print final mesh check --- .../generation/snappyHexMesh/snappyHexMesh.C | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 2406cb667c..14bf0ee9eb 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -47,6 +47,8 @@ Description #include "snapParameters.H" #include "layerParameters.H" #include "vtkSetWriter.H" +#include "faceSet.H" +#include "motionSmoother.H" using namespace Foam; @@ -675,6 +677,31 @@ int main(int argc, char *argv[]) } + { + // Check final mesh + Info<< "Checking final mesh ..." << endl; + faceSet wrongFaces(mesh, "wrongFaces", mesh.nFaces()/100); + motionSmoother::checkMesh(false, mesh, motionDict, wrongFaces); + const label nErrors = returnReduce + ( + wrongFaces.size(), + sumOp