From 74f56fec0f06c42110f7dd08d56c8f1da2d370b4 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 16 Mar 2011 12:29:47 +0000 Subject: [PATCH 01/27] ENH: add option for version --- bin/tools/foamConfigurePaths | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) mode change 100644 => 100755 bin/tools/foamConfigurePaths diff --git a/bin/tools/foamConfigurePaths b/bin/tools/foamConfigurePaths old mode 100644 new mode 100755 index 4cc15532c6..f3948c3cc2 --- a/bin/tools/foamConfigurePaths +++ b/bin/tools/foamConfigurePaths @@ -37,6 +37,7 @@ usage() { usage: ${0##*/} --foamInstall dir specify installation directory (e.g. /opt) --projectName name specify project name (e.g. openfoam170) + --projectVersion ver specify project version (e.g. 1.7.x) --archOption arch specify architecture option (only 32 or 64 applicable) --paraviewInstall dir specify ParaView_DIR (e.g. /opt/paraviewopenfoam380) @@ -76,7 +77,7 @@ _inlineSed() [ -f etc/bashrc ] || usage "Please run from top-level directory of installation" -unset foamInstall projectName archOption paraviewInstall +unset foamInstall projectName projectVersion archOption paraviewInstall # parse options while [ "$#" -gt 0 ] @@ -102,7 +103,17 @@ do _inlineSed \ etc/bashrc \ '/^[^#]/s@WM_PROJECT_DIR=.*@WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/'"$projectName@" \ - "Replacing WM_PROJECT_DIR setting by '$projectName'" + "Replacing WM_PROJECT_DIR setting by $projectName" + shift 2 + ;; + --projectVersion) + [ "$#" -ge 2 ] || usage "'$1' option requires an argument" + projectVersion="$2" + # replace WM_PROJECT_VERSION=... + _inlineSed \ + etc/bashrc \ + '/^[^#]/s@WM_PROJECT_VERSION=.*@WM_PROJECT_VERSION='"$projectVersion@" \ + "Replacing WM_PROJECT_VERSION setting by $projectVersion" shift 2 ;; -archOption | --archOption) @@ -142,10 +153,10 @@ _inlineSed \ '/^[^#]/s@export WM_MPLIB=.*@export WM_MPLIB=SYSTEMOPENMPI@' \ "Replacing WM_MPLIB setting by 'SYSTEMOPENMPI'" -# set foamCompiler=system always -_inlineSed \ - etc/bashrc \ - '/^[^#]/s@foamCompiler=.*@foamCompiler=system@' \ - "Replacing foamCompiler setting by 'system'" +## set foamCompiler=system always +#_inlineSed \ +# etc/bashrc \ +# '/^[^#]/s@foamCompiler=.*@foamCompiler=system@' \ +# "Replacing foamCompiler setting by 'system'" #------------------------------------------------------------------------------ From 7e810605fe9277fb3f219a5092f8a1aef800711a Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 8 Apr 2011 10:03:02 +0100 Subject: [PATCH 02/27] ENH: Updated kinematic cloud theta field calculation --- .../KinematicCloud/KinematicCloudI.H | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H index 5987192bfd..568d089030 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H @@ -370,42 +370,22 @@ Foam::KinematicCloud::theta() const false ), mesh_, - dimensionedScalar("zero", dimless, 0.0) + dimensionedScalar("zero", dimless, 0.0), + zeroGradientFvPatchScalarField::typeName ) ); volScalarField& theta = ttheta(); - theta.boundaryField() == 0; - forAllConstIter(typename KinematicCloud, *this, iter) { const parcelType& p = iter(); const label cellI = p.cell(); - if ((p.face() != -1)) - { - const label patchI = p.patch(p.face()); - if (patchI != -1) - { - scalarField& thetap = theta.boundaryField()[patchI]; - const label faceI = p.patchFace(patchI, p.face()); - thetap[faceI] += p.nParticle()*p.areaP(); - } - } - theta[cellI] += p.nParticle()*p.volume(); } theta.internalField() /= mesh_.V(); - - forAll(theta.boundaryField(), patchI) - { - scalarField& thetap = theta.boundaryField()[patchI]; - if (thetap.size() > 0) - { - thetap /= mesh_.magSf().boundaryField()[patchI]; - } - } + theta.correctBoundaryConditions(); return ttheta; } From d1fdcc2698c9a6c5e32428a270493f1b4a5a0e71 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 8 Apr 2011 10:05:07 +0100 Subject: [PATCH 03/27] STYLE: minor code changes --- src/OpenFOAM/db/IOstreams/token/token.H | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/db/IOstreams/token/token.H b/src/OpenFOAM/db/IOstreams/token/token.H index c48c22b5c3..0497c75e8d 100644 --- a/src/OpenFOAM/db/IOstreams/token/token.H +++ b/src/OpenFOAM/db/IOstreams/token/token.H @@ -435,11 +435,11 @@ Ostream& operator<<(Ostream&, const token::compound&); #define defineCompoundTypeName(Type, Name) \ - typedef token::Compound tokenCompound##Name##_; \ + typedef token::Compound tokenCompound##Name##_; \ defineTemplateTypeNameAndDebugWithName(tokenCompound##Name##_, #Type, 0); #define addCompoundToRunTimeSelectionTable(Type, Name) \ - token::compound::addIstreamConstructorToTable > \ + token::compound::addIstreamConstructorToTable > \ add##Name##IstreamConstructorToTable_; From 386dd53f44beaaa4b427df57c200ad26db2eda76 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 8 Apr 2011 15:09:19 +0100 Subject: [PATCH 04/27] ENH:autoSnapDriver: added support for facezones --- .../autoHexMeshDriver/autoSnapDriver.C | 60 +-- .../autoHexMeshDriver/autoSnapDriver.H | 12 +- .../autoHexMeshDriver/autoSnapDriverFeature.C | 433 ++++++------------ .../meshRefinement/meshRefinementMerge.C | 48 +- 4 files changed, 219 insertions(+), 334 deletions(-) diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C index 3787156a53..6c1925f064 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C @@ -722,10 +722,15 @@ void Foam::autoSnapDriver::preSmoothPatch if (debug) { const_cast(mesh.time())++; - Pout<< "Writing patch smoothed mesh to time " << meshRefiner_.timeName() - << endl; - - mesh.write(); + Pout<< "Writing patch smoothed mesh to time " + << meshRefiner_.timeName() << '.' << endl; + meshRefiner_.write + ( + debug, + mesh.time().path()/meshRefiner_.timeName() + ); + Pout<< "Dumped mesh in = " + << mesh.time().cpuTimeIncrement() << " s\n" << nl << endl; } Info<< "Patch points smoothed in = " @@ -956,25 +961,6 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface vector(GREAT, GREAT, GREAT) // null value (note: cannot use VGREAT) ); - - // Check for displacement being outwards. - outwardsDisplacement(pp, patchDisp); - - // Set initial distribution of displacement field (on patches) from - // patchDisp and make displacement consistent with b.c. on displacement - // pointVectorField. - meshMover.setDisplacement(patchDisp); - - if (debug) - { - dumpMove - ( - mesh.time().path()/"patchDisplacement.obj", - pp.localPoints(), - pp.localPoints() + patchDisp - ); - } - return patchDisp; } @@ -1128,8 +1114,8 @@ Foam::autoPtr Foam::autoSnapDriver::repatchToSurface indirectPrimitivePatch& pp = ppPtr(); // Divide surfaces into zoned and unzoned - labelList zonedSurfaces = meshRefiner_.surfaces().getNamedSurfaces(); - labelList unzonedSurfaces = meshRefiner_.surfaces().getUnnamedSurfaces(); + labelList zonedSurfaces = surfaces.getNamedSurfaces(); + labelList unzonedSurfaces = surfaces.getUnnamedSurfaces(); // Faces that do not move @@ -1344,19 +1330,6 @@ void Foam::autoSnapDriver::doSnap // Pre-smooth patch vertices (so before determining nearest) preSmoothPatch(snapParams, nInitErrors, baffles, meshMover); - if (debug) - { - Pout<< "Writing patch smoothed mesh to time " - << meshRefiner_.timeName() << '.' << endl; - meshRefiner_.write - ( - debug, - mesh.time().path()/meshRefiner_.timeName() - ); - Pout<< "Dumped mesh in = " - << mesh.time().cpuTimeIncrement() << " s\n" << nl << endl; - } - for (label iter = 0; iter < nFeatIter; iter++) { @@ -1382,6 +1355,15 @@ void Foam::autoSnapDriver::doSnap ); } + // Check for displacement being outwards. + outwardsDisplacement(ppPtr(), disp); + + // Set initial distribution of displacement field (on patches) + // from patchDisp and make displacement consistent with b.c. + // on displacement pointVectorField. + meshMover.setDisplacement(disp); + + if (debug&meshRefinement::OBJINTERSECTIONS) { dumpMove @@ -1467,7 +1449,7 @@ void Foam::autoSnapDriver::doSnap meshRefiner_.write ( debug, - mesh.time().path()/meshRefiner_.timeName() + meshRefiner_.timeName() ); } } diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.H b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.H index 4b0e1a30fd..59cd772a98 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.H +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.H @@ -117,12 +117,12 @@ class autoSnapDriver const List& constraints, vectorField& disp ) const; - void calcNearest - ( - const pointField& points, - vectorField& disp, - vectorField& surfaceNormal - ) const; + //void calcNearest + //( + // const pointField& points, + // vectorField& disp, + // vectorField& surfaceNormal + //) const; void calcNearestFace ( const label iter, diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C index cc73efbe51..0227234822 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C @@ -135,63 +135,6 @@ void Foam::autoSnapDriver::smoothAndConstrain } -void Foam::autoSnapDriver::calcNearest -( - const pointField& points, - vectorField& disp, - vectorField& surfaceNormal -) const -{ - const refinementSurfaces& surfaces = meshRefiner_.surfaces(); - - // Displacement and orientation per pp face. - disp.setSize(points.size()); - disp = vector::zero; - surfaceNormal.setSize(points.size()); - surfaceNormal = vector::zero; - - { - // Divide surfaces into zoned and unzoned - labelList zonedSurfaces = - meshRefiner_.surfaces().getNamedSurfaces(); - labelList unzonedSurfaces = - meshRefiner_.surfaces().getUnnamedSurfaces(); - - { - List hitInfo; - labelList hitSurface; - labelList hitRegion; - surfaces.findNearestRegion - ( - unzonedSurfaces, - points, - sqr(scalarField(points.size(), GREAT)),// sqr of attract dist - hitSurface, - hitInfo, - hitRegion, - surfaceNormal - ); - - forAll(hitInfo, i) - { - if (hitInfo[i].hit()) - { - disp[i] = - hitInfo[i].hitPoint() - - points[i]; - } - else - { - WarningIn("calcNearest(..)") - << "Did not hit anything from face:" << i - << " at:" << points[i] << endl; - } - } - } - } -} - - void Foam::autoSnapDriver::calcNearestFace ( const label iter, @@ -202,6 +145,7 @@ void Foam::autoSnapDriver::calcNearestFace ) const { const fvMesh& mesh = meshRefiner_.mesh(); + const refinementSurfaces& surfaces = meshRefiner_.surfaces(); // Displacement and orientation per pp face. faceDisp.setSize(pp.size()); @@ -209,7 +153,148 @@ void Foam::autoSnapDriver::calcNearestFace faceSurfaceNormal.setSize(pp.size()); faceSurfaceNormal = vector::zero; - calcNearest(pp.faceCentres(), faceDisp, faceSurfaceNormal); + // Divide surfaces into zoned and unzoned + labelList zonedSurfaces = surfaces.getNamedSurfaces(); + labelList unzonedSurfaces = surfaces.getUnnamedSurfaces(); + + // Per pp face the current surface snapped to + labelList snapSurf(pp.size(), -1); + + + // Do zoned surfaces + // ~~~~~~~~~~~~~~~~~ + // Zoned faces only attract to corresponding surface + + // Extract faces per zone + const wordList& faceZoneNames = surfaces.faceZoneNames(); + + forAll(zonedSurfaces, i) + { + label zoneSurfI = zonedSurfaces[i]; + + // Get indices of faces on pp that are also in zone + label zoneI = mesh.faceZones().findZoneID(faceZoneNames[zoneSurfI]); + if (zoneI == -1) + { + FatalErrorIn + ( + "autoSnapDriver::calcNearestFace(..)" + ) << "Problem. Cannot find zone " << faceZoneNames[zoneSurfI] + << exit(FatalError); + } + const faceZone& fZone = mesh.faceZones()[zoneI]; + PackedBoolList isZonedFace(mesh.nFaces()); + forAll(fZone, i) + { + isZonedFace[fZone[i]] = 1; + } + + DynamicList