From d69ed586dd8e3d1df5b31c0bf037f57c201419ae Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 6 Sep 2010 14:28:24 +0100 Subject: [PATCH 01/32] BUG: constant::mathematical::pi --- .../kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C index 6354144176..ee2300d91e 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C @@ -200,7 +200,7 @@ void Foam::kineticTheoryModel::solve(const volTensorField& gradUat) return; } - const scalar sqrtPi = sqrt(mathematicalConstant::pi); + const scalar sqrtPi = sqrt(constant::mathematical::pi); surfaceScalarField phi = 1.5*rhoa_*phia_*fvc::interpolate(alpha_); From 34806371b125f80c0ff857c3a92e031721dd6ea8 Mon Sep 17 00:00:00 2001 From: graham Date: Thu, 11 Nov 2010 17:48:35 +0000 Subject: [PATCH 02/32] BUG: must trigger polyMesh_.tetBasePtIs(); in all Cloud constructors. --- src/lagrangian/basic/Cloud/Cloud.C | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C index 5a6fb49d0f..d2331a1f2e 100644 --- a/src/lagrangian/basic/Cloud/Cloud.C +++ b/src/lagrangian/basic/Cloud/Cloud.C @@ -84,6 +84,11 @@ Foam::Cloud::Cloud nTrackingRescues_(), cellWallFacesPtr_() { + // Ask for the tetBasePtIs to trigger all processors to build + // them, otherwise, if some processors have no particles then + // there is a comms mismatch. + polyMesh_.tetBasePtIs(); + IDLList::operator=(particles); } @@ -105,6 +110,11 @@ Foam::Cloud::Cloud nTrackingRescues_(), cellWallFacesPtr_() { + // Ask for the tetBasePtIs to trigger all processors to build + // them, otherwise, if some processors have no particles then + // there is a comms mismatch. + polyMesh_.tetBasePtIs(); + IDLList::operator=(particles); } From f53538b831d711029f533fc9af04f0a016c1e34b Mon Sep 17 00:00:00 2001 From: graham Date: Thu, 11 Nov 2010 17:49:22 +0000 Subject: [PATCH 03/32] BUG: stitchTriangles reordering the points, not renumbering the tris. --- src/triSurface/triSurface/stitchTriangles.C | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/triSurface/triSurface/stitchTriangles.C b/src/triSurface/triSurface/stitchTriangles.C index f58e3d464f..8771aeaec5 100644 --- a/src/triSurface/triSurface/stitchTriangles.C +++ b/src/triSurface/triSurface/stitchTriangles.C @@ -46,13 +46,14 @@ bool triSurface::stitchTriangles pointField newPoints; bool hasMerged = mergePoints(rawPoints, tol, verbose, pointMap, newPoints); - pointField& ps = storedPoints(); - - // Set the coordinates to the merged ones - ps.transfer(newPoints); - if (hasMerged) { + pointField& ps = storedPoints(); + + // Set the coordinates to the merged ones + ps.transfer(newPoints); + + if (verbose) { Pout<< "stitchTriangles : Merged from " << rawPoints.size() From 8490014bf6b0e4d06ea93d2133101cbba02163e7 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 12 Nov 2010 12:13:28 +0000 Subject: [PATCH 04/32] rhoSimplecFoam: further developments not entirely satisfactory --- .../compressible/rhoSimplecFoam/UEqn.H | 11 -------- .../compressible/rhoSimplecFoam/hEqn.H | 28 ------------------- .../compressible/rhoSimplecFoam/pEqn.H | 10 +++++-- .../rhoSimplecFoam/rhoSimplecFoam.C | 1 + 4 files changed, 9 insertions(+), 41 deletions(-) delete mode 100644 applications/solvers/compressible/rhoSimplecFoam/UEqn.H delete mode 100644 applications/solvers/compressible/rhoSimplecFoam/hEqn.H diff --git a/applications/solvers/compressible/rhoSimplecFoam/UEqn.H b/applications/solvers/compressible/rhoSimplecFoam/UEqn.H deleted file mode 100644 index 21ec2646be..0000000000 --- a/applications/solvers/compressible/rhoSimplecFoam/UEqn.H +++ /dev/null @@ -1,11 +0,0 @@ - // Solve the Momentum equation - - tmp UEqn - ( - fvm::div(phi, U) - + turbulence->divDevRhoReff(U) - ); - - UEqn().relax(); - - solve(UEqn() == -fvc::grad(p)); diff --git a/applications/solvers/compressible/rhoSimplecFoam/hEqn.H b/applications/solvers/compressible/rhoSimplecFoam/hEqn.H deleted file mode 100644 index bec9ed3ae0..0000000000 --- a/applications/solvers/compressible/rhoSimplecFoam/hEqn.H +++ /dev/null @@ -1,28 +0,0 @@ -{ - fvScalarMatrix hEqn - ( - fvm::div(phi, h) - - fvm::Sp(fvc::div(phi), h) - - fvm::laplacian(turbulence->alphaEff(), h) - == - fvc::div(phi/fvc::interpolate(rho)*fvc::interpolate(p, "div(U,p)")) - - p*fvc::div(phi/fvc::interpolate(rho)) - ); - - hEqn.relax(); - - hEqn.solve(); - - thermo.correct(); - - rho = thermo.rho(); - - if (!transonic) - { - rho.relax(); - } - - Info<< "rho max/min : " - << max(rho).value() << " " - << min(rho).value() << endl; -} diff --git a/applications/solvers/compressible/rhoSimplecFoam/pEqn.H b/applications/solvers/compressible/rhoSimplecFoam/pEqn.H index 43443a507b..2e370cc447 100644 --- a/applications/solvers/compressible/rhoSimplecFoam/pEqn.H +++ b/applications/solvers/compressible/rhoSimplecFoam/pEqn.H @@ -1,3 +1,8 @@ +rho = thermo.rho(); +rho = max(rho, rhoMin); +rho = min(rho, rhoMax); +rho.relax(); + volScalarField p0 = p; volScalarField AU = UEqn().A(); @@ -24,8 +29,8 @@ if (transonic) + phid*(fvc::interpolate(p) - fvc::interpolate(p, "UD")) ); - refCast(p.boundaryField()[1]).refValue() - = p.boundaryField()[1]; + //refCast(p.boundaryField()[1]).refValue() + // = p.boundaryField()[1]; fvScalarMatrix pEqn ( @@ -35,6 +40,7 @@ if (transonic) + fvc::div(phid)*p - fvm::laplacian(rho/AtU, p) ); + //pEqn.relax(); pEqn.setReference(pRefCell, pRefValue); diff --git a/applications/solvers/compressible/rhoSimplecFoam/rhoSimplecFoam.C b/applications/solvers/compressible/rhoSimplecFoam/rhoSimplecFoam.C index 541e7b388f..c959cfdd3e 100644 --- a/applications/solvers/compressible/rhoSimplecFoam/rhoSimplecFoam.C +++ b/applications/solvers/compressible/rhoSimplecFoam/rhoSimplecFoam.C @@ -57,6 +57,7 @@ int main(int argc, char *argv[]) #include "readSIMPLEControls.H" p.storePrevIter(); + rho.storePrevIter(); if (!transonic) { From 1fab38aae30efc049d126d34ef7ca2abed32b7bf Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 12 Nov 2010 12:48:10 +0000 Subject: [PATCH 05/32] ENH: Additional output when face is non-single --- src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C index 8eaf3559f5..abea829e3f 100644 --- a/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C +++ b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C @@ -211,7 +211,8 @@ void Foam::singleCellFvMesh::agglomerateMesh "singleCellFvMesh::agglomerateMesh(..)" ) << "agglomeration does not create a" << " single, non-manifold" - << " face for agglomeration " << coarseI + << " face for agglomeration " << myAgglom + << " on patch " << patchI << exit(FatalError); } From 8b31f15a3d70350eef13f5a3895e902c9c81e8c9 Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 12 Nov 2010 13:02:24 +0000 Subject: [PATCH 06/32] ENH: e1 reCalculation --- .../timeVaryingMappedFixedValueFvPatchField.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C index ae44316ef0..0f1ea4cd6f 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C @@ -271,7 +271,7 @@ void timeVaryingMappedFixedValueFvPatchField::readSamplePoints() maxDist = magE1; } } - + e1 = samplePoints[i] - p0; // Find point that is furthest away from line p0-p1 const point& p1 = samplePoints[index1]; From 7819ab5037e0d0a3ebe1dbda54de88381c496532 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 12 Nov 2010 14:30:27 +0000 Subject: [PATCH 07/32] ENH: argList : expand roots for distributed running --- src/OpenFOAM/global/argList/argList.C | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index c31199c993..f0aacffb03 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -567,6 +567,10 @@ Foam::argList::argList { fileNameList roots; decompDict.lookup("roots") >> roots; + forAll(roots, i) + { + roots[i] = roots[i].expand(); + } if (roots.size() != Pstream::nProcs()-1) { From 67542c857761e84d22abaf6745fc1d94edcc4020 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 12 Nov 2010 14:31:00 +0000 Subject: [PATCH 08/32] BUG: meshRefinementRefine : track to end --- .../autoHexMesh/meshRefinement/meshRefinementRefine.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C index 7c445b2432..98b0a34ae7 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C @@ -333,7 +333,7 @@ Foam::label Foam::meshRefinement::markFeatureRefinement trackedParticle::trackData td(cloud, maxFeatureLevel); // Track all particles to their end position (= starting feature point) - cloud.move(td, mesh_.time().deltaTValue()); + cloud.move(td, GREAT); // Reset level maxFeatureLevel = -1; @@ -406,7 +406,7 @@ Foam::label Foam::meshRefinement::markFeatureRefinement } // Track all particles to their end position. - cloud.move(td, mesh_.time().deltaTValue()); + cloud.move(td, GREAT); } From 8be22e5176bb48794eb6bbbd9c64c28e1a348418 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 12 Nov 2010 14:31:50 +0000 Subject: [PATCH 09/32] ENH: mppirunDebug : allow systemopenmpi --- bin/mpirunDebug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/mpirunDebug b/bin/mpirunDebug index 3b0c6f7fce..3c4aaf6a9a 100755 --- a/bin/mpirunDebug +++ b/bin/mpirunDebug @@ -221,7 +221,7 @@ done unset cmd case "$WM_MPLIB" in -OPENMPI) +*OPENMPI) cmd="mpirun -app $PWD/mpirun.schema Date: Fri, 12 Nov 2010 14:32:31 +0000 Subject: [PATCH 10/32] ENH: set MPI_ARCH_PATCH for ThirdParty Allwmake --- etc/settings.csh | 7 ++++--- etc/settings.sh | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/etc/settings.csh b/etc/settings.csh index 8159eed539..4fd95a1c9d 100644 --- a/etc/settings.csh +++ b/etc/settings.csh @@ -236,11 +236,12 @@ case OPENMPI: breaksw case SYSTEMOPENMPI: - - # This uses the installed openmpi. It needs mpicc installed! - + # use the system installed openmpi, get library directory via mpicc set mpi_version=openmpi-system + # Set to dummy value (but existing directory) + setenv MPI_ARCH_PATH / + # Set compilation flags here instead of in wmake/rules/../mplibSYSTEMOPENMPI setenv PINC "`mpicc --showme:compile`" setenv PLIBS "`mpicc --showme:link`" diff --git a/etc/settings.sh b/etc/settings.sh index 5b53c59f2b..9f46523377 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -264,6 +264,9 @@ SYSTEMOPENMPI) # use the system installed openmpi, get library directory via mpicc mpi_version=openmpi-system + # Set to dummy (but existing directory). Used in Thirdparty Allwmake. + export MPI_ARCH_PATH=/ + # Set compilation flags here instead of in wmake/rules/../mplibSYSTEMOPENMPI export PINC="`mpicc --showme:compile`" export PLIBS="`mpicc --showme:link`" From 27f7005422b3d6ba61652c76d4952a09f916f300 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 12 Nov 2010 14:33:27 +0000 Subject: [PATCH 11/32] STYLE: surfaceInterpolateFields : updated comment --- .../surfaceInterpolateFields/surfaceInterpolateFields.H | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.H b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.H index ef804d755c..d8da89b440 100644 --- a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.H +++ b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.H @@ -25,8 +25,11 @@ Class Foam::surfaceInterpolateFields Description - Reads fields from the time folders and adds them to the mesh database - for further post-processing. + Linear interpolates volFields to surfaceFields + + Note: gets executed every time step. Could move it to write() but then + you'd have problems if you have different write frequencies for different + function objects. SourceFiles surfaceInterpolateFields.C @@ -38,7 +41,6 @@ SourceFiles #define surfaceInterpolateFields_H #include "OFstream.H" -//#include "pointFieldFwd.H" #include "surfaceFields.H" #include "Tuple2.H" From d5132b7ba8c1ca9651ee3c91c2a78c01511a1279 Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 12 Nov 2010 15:11:06 +0000 Subject: [PATCH 12/32] BUG: Correct calculation of e1 --- .../timeVaryingMappedFixedValueFvPatchField.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C index 0f1ea4cd6f..8f91848fa4 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C @@ -271,7 +271,7 @@ void timeVaryingMappedFixedValueFvPatchField::readSamplePoints() maxDist = magE1; } } - e1 = samplePoints[i] - p0; + e1 = samplePoints[index1] - p0; // Find point that is furthest away from line p0-p1 const point& p1 = samplePoints[index1]; From efd658ec0e249a2ae8ca51acaac7652398795c7a Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 15 Nov 2010 11:22:00 +0000 Subject: [PATCH 13/32] STYLE: wallPointI.H : extaneous comment --- .../fvMesh/wallDist/wallPointYPlus/wallPointYPlusI.H | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/finiteVolume/fvMesh/wallDist/wallPointYPlus/wallPointYPlusI.H b/src/finiteVolume/fvMesh/wallDist/wallPointYPlus/wallPointYPlusI.H index 51f53d3edc..a9bab14083 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallPointYPlus/wallPointYPlusI.H +++ b/src/finiteVolume/fvMesh/wallDist/wallPointYPlus/wallPointYPlusI.H @@ -21,8 +21,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Description - \*---------------------------------------------------------------------------*/ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -32,7 +30,6 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - // Update this with w2 if w2 nearer to pt. inline bool wallPointYPlus::update ( From 1eb93102dac756ec247273122674d0af413e4b0d Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 15 Nov 2010 11:22:51 +0000 Subject: [PATCH 14/32] STYLE: treeBoundBox : error message --- src/meshTools/octree/treeBoundBox.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meshTools/octree/treeBoundBox.C b/src/meshTools/octree/treeBoundBox.C index eab4694b3b..8906affeaa 100644 --- a/src/meshTools/octree/treeBoundBox.C +++ b/src/meshTools/octree/treeBoundBox.C @@ -134,7 +134,7 @@ Foam::treeBoundBox::treeBoundBox(const UList& points) WarningIn ( "treeBoundBox::treeBoundBox(const UList&)" - ) << "cannot find bounding box for zero-sized pointField" + ) << "cannot find bounding box for zero-sized pointField, " << "returning zero" << endl; return; From a0806f5aca31eb3efadb68b56aba310b81414e21 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 15 Nov 2010 15:11:10 +0000 Subject: [PATCH 15/32] STYLE: directMappedVelocityFluxFixedValue : updated comment --- .../directMappedVelocityFluxFixedValueFvPatchField.H | 1 - 1 file changed, 1 deletion(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.H index 3aecda00c0..1c1333acab 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.H @@ -27,7 +27,6 @@ Class Description Recycles the velocity and flux at a patch to this patch - mode = NEARESTCELL : sample nearest cell mode = NEARESTPATCHFACE : sample nearest face on selected patch mode = NEARESTFACE : sample nearest face on any patch. Note: does not warn if nearest actually is on internal face! From aee09dd35c55571c17a86a03b704e75b1e7c8dab Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 15 Nov 2010 16:22:16 +0000 Subject: [PATCH 16/32] BUG: dynamicRefineFvMesh : error calculation, reading dictionary --- .../dynamicRefineFvMesh/dynamicRefineFvMesh.C | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C b/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C index 4a3da9f7f3..6ea8c123d0 100644 --- a/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C +++ b/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C @@ -620,24 +620,23 @@ Foam::dynamicRefineFvMesh::cellToPoint(const scalarField& vFld) const } -// Calculate error. Is < 0 or distance from inbetween levels -Foam::scalarField -Foam::dynamicRefineFvMesh::error +// Calculate error. Is < 0 or distance to minLevel, maxLevel +Foam::scalarField Foam::dynamicRefineFvMesh::error ( const scalarField& fld, const scalar minLevel, const scalar maxLevel ) const { - const scalar halfLevel = 0.5*(minLevel + maxLevel); - scalarField c(fld.size(), -1); forAll(fld, i) { - if (fld[i] >= minLevel && fld[i] < maxLevel) + scalar err = min(fld[i]-minLevel, maxLevel-fld[i]); + + if (err >= 0) { - c[i] = mag(fld[i] - halfLevel); + c[i] = err; } } return c; @@ -877,6 +876,10 @@ Foam::dynamicRefineFvMesh::dynamicRefineFvMesh(const IOobject& io) nRefinementIterations_(0), protectedCell_(nCells(), 0) { + // Read static part of dictionary + readDict(); + + const labelList& cellLevel = meshCutter_.cellLevel(); const labelList& pointLevel = meshCutter_.pointLevel(); From 9fc20c4e167026b6b4c5ba39312dd593b2994b4b Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 15 Nov 2010 17:01:36 +0000 Subject: [PATCH 17/32] ENH: featureEdgeMesh : merge from cvm --- .../featureEdgeMesh/featureEdgeMeshI.H | 249 ++++++++++++++++++ 1 file changed, 249 insertions(+) create mode 100644 src/edgeMesh/featureEdgeMesh/featureEdgeMeshI.H diff --git a/src/edgeMesh/featureEdgeMesh/featureEdgeMeshI.H b/src/edgeMesh/featureEdgeMesh/featureEdgeMeshI.H new file mode 100644 index 0000000000..162f17a1a5 --- /dev/null +++ b/src/edgeMesh/featureEdgeMesh/featureEdgeMeshI.H @@ -0,0 +1,249 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline Foam::label Foam::featureEdgeMesh::convexStart() const +{ + return convexStart_; +} + + +inline Foam::label Foam::featureEdgeMesh::concaveStart() const +{ + return concaveStart_; +} + + +inline Foam::label Foam::featureEdgeMesh::mixedStart() const +{ + return mixedStart_; +} + + +inline Foam::label Foam::featureEdgeMesh::nonFeatureStart() const +{ + return nonFeatureStart_; +} + + +inline Foam::label Foam::featureEdgeMesh::externalStart() const +{ + return externalStart_; +} + + +inline Foam::label Foam::featureEdgeMesh::internalStart() const +{ + return internalStart_; +} + + +inline Foam::label Foam::featureEdgeMesh::flatStart() const +{ + return flatStart_; +} + + +inline Foam::label Foam::featureEdgeMesh::openStart() const +{ + return openStart_; +} + + +inline Foam::label Foam::featureEdgeMesh::multipleStart() const +{ + return multipleStart_; +} + + +inline bool Foam::featureEdgeMesh::featurePoint(label ptI) const +{ + return ptI < nonFeatureStart_; +} + + +inline const Foam::vectorField& Foam::featureEdgeMesh::normals() const +{ + return normals_; +} + +inline const Foam::vectorField& Foam::featureEdgeMesh::edgeDirections() const +{ + return edgeDirections_; +} + + +inline Foam::vector Foam::featureEdgeMesh::edgeDirection +( + label edgeI, + label ptI +) const +{ + const edge& e = edges()[edgeI]; + + if (ptI == e.start()) + { + return edgeDirections()[edgeI]; + } + else if (ptI == e.end()) + { + return -edgeDirections()[edgeI]; + } + else + { + FatalErrorIn("Foam::featureEdgeMesh::edgedirection") + << "Requested ptI " << ptI << " is not a point on the requested " + << "edgeI " << edgeI << ". edgeI start and end: " + << e.start() << " " << e.end() + << exit(FatalError); + + return vector::zero; + } +} + + +inline const Foam::labelListList& Foam::featureEdgeMesh::edgeNormals() const +{ + return edgeNormals_; +} + + +inline Foam::vectorField Foam::featureEdgeMesh::edgeNormals +( + const labelList& edgeNormIs +) const +{ + vectorField norms(edgeNormIs.size()); + + forAll(edgeNormIs, i) + { + norms[i] = normals_[edgeNormIs[i]]; + } + + return norms; +} + + +inline Foam::vectorField Foam::featureEdgeMesh::edgeNormals(label edgeI) const +{ + return edgeNormals(edgeNormals_[edgeI]); +} + + +inline const Foam::labelListList& +Foam::featureEdgeMesh::featurePointNormals() const +{ + return featurePointNormals_; +} + + +inline Foam::vectorField Foam::featureEdgeMesh::featurePointNormals +( + label ptI +) const +{ + if (!featurePoint(ptI)) + { + WarningIn("vectorField featureEdgeMesh::featurePointNormals") + << "Requesting the normals of a non-feature point. " + << "Returned zero length vectorField." + << endl; + + return vectorField(0); + } + + labelList featPtNormIs(featurePointNormals_[ptI]); + + vectorField norms(featPtNormIs.size()); + + forAll(featPtNormIs, i) + { + norms[i] = normals_[featPtNormIs[i]]; + } + + return norms; +} + + +inline const Foam::labelList& Foam::featureEdgeMesh::regionEdges() const +{ + return regionEdges_; +} + + +inline Foam::featureEdgeMesh::pointStatus Foam::featureEdgeMesh::getPointStatus +( + label ptI +) const +{ + if (ptI < concaveStart_) + { + return CONVEX; + } + else if (ptI < mixedStart_) + { + return CONCAVE; + } + else if (ptI < nonFeatureStart_) + { + return MIXED; + } + else + { + return NONFEATURE; + } +} + + +inline Foam::featureEdgeMesh::edgeStatus Foam::featureEdgeMesh::getEdgeStatus +( + label edgeI +) const +{ + if (edgeI < internalStart_) + { + return EXTERNAL; + } + else if (edgeI < flatStart_) + { + return INTERNAL; + } + else if (edgeI < openStart_) + { + return FLAT; + } + else if (edgeI < multipleStart_) + { + return OPEN; + } + else + { + return MULTIPLE; + } +} + + +// ************************************************************************* // From 13b458eb5a7cec35761bfea3a7ab67264013f7c2 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 15 Nov 2010 17:07:46 +0000 Subject: [PATCH 18/32] BUG: timeVaryingMappedFixedValue : find furthest away point --- .../timeVaryingMappedFixedValueFvPatchField.C | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C index 8f91848fa4..007038b2bf 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C @@ -261,17 +261,16 @@ void timeVaryingMappedFixedValueFvPatchField::readSamplePoints() for (label i = 1; i < samplePoints.size(); i++) { - e1 = samplePoints[i] - p0; - scalar magE1 = mag(e1); + const vector d = samplePoints[i] - p0; + scalar magD = mag(d); - if (magE1 > maxDist) + if (magD > maxDist) { - e1 /= magE1; + e1 = d/magD; index1 = i; - maxDist = magE1; + maxDist = magD; } } - e1 = samplePoints[index1] - p0; // Find point that is furthest away from line p0-p1 const point& p1 = samplePoints[index1]; From 57a443a1834d46f8f8d1fdc07e1cef20b2d6a17c Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 16 Nov 2010 12:38:07 +0000 Subject: [PATCH 19/32] STYLE: functionObjectList : indentation --- .../functionObjectList/functionObjectList.C | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 2515b0b161..a4c3225d3a 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -198,7 +198,13 @@ bool Foam::functionObjectList::read() } // Update existing and add new functionObjects - const entry* entryPtr = parentDict_.lookupEntryPtr("functions",false,false); + const entry* entryPtr = parentDict_.lookupEntryPtr + ( + "functions", + false, + false + ); + if (entryPtr) { PtrList newPtrs; From b5dddd8980d4591f705be0f5b291838ddd7ff837 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 16 Nov 2010 12:41:44 +0000 Subject: [PATCH 20/32] ENH: parallel runTimeModifiable - master only --- doc/changes/inotify.txt | 59 +- etc/controlDict | 8 + src/OSspecific/POSIX/Allwmake | 4 +- src/OSspecific/POSIX/fileMonitor.C | 540 +++++++++++------- src/OSspecific/POSIX/fileMonitor.H | 18 +- .../db/IOobjects/IOdictionary/IOdictionary.C | 109 +++- .../db/IOobjects/IOdictionary/IOdictionary.H | 5 + src/OpenFOAM/db/Time/Time.C | 46 +- src/OpenFOAM/db/Time/TimeIO.C | 9 +- src/OpenFOAM/db/regIOobject/regIOobject.C | 36 +- src/OpenFOAM/db/regIOobject/regIOobject.H | 17 + src/OpenFOAM/db/regIOobject/regIOobjectRead.C | 48 +- src/OpenFOAM/global/argList/argList.C | 76 ++- 13 files changed, 700 insertions(+), 275 deletions(-) diff --git a/doc/changes/inotify.txt b/doc/changes/inotify.txt index 146dc55a05..35b50ee2d4 100644 --- a/doc/changes/inotify.txt +++ b/doc/changes/inotify.txt @@ -24,21 +24,63 @@ be quite a gain on large numbers of processors. - all file monitoring is done by an instance of 'fileMonitor' in the Time -class. The fileMonitor class can be found in OSspecific. Default is -to use the (linux-specific) 'inotify' system calls. -If compiled with -DFOAM_USE_STAT it will revert to the current 'stat' system -calls. +class. The fileMonitor class can be found in OSspecific. It uses either +timestamps as before or the (linux-specific) 'inotify' system framework +(available only if compiled with -DFOAM_USE_INOTIFY). -- inotify does not need timestamps. There is no need for fileModificationSkew +- the monitoring can be done in one of four modes as set by + OptimisationSwitches::fileModificationChecking + + - timeStamp : old behaviour : all nodes check the timestamp + - inotify : using inotify instead of timestamps + - timeStampMaster,inotifyMaster : only the master node checks the file + and only the master node reads it and distribute it to the + slaves. This makes runTimeModifiable possible on distributed + running (see below). + +- distributed running: + - set fileModificationChecking to e.g. timeStampMaster + - decompose a case, e.g. cavity + - copy system and constant to processor0/ + - put the all the processor* directories on the wanted nodes inside + the case directory. E.g. + - on master have /tmp/cavity/processor0 + - on slaveN have /tmp/cavity/processorN + - so to reiterate: + - there is no need for cavity/constant or cavity/system, all the + dictionaries are only in processor0/constant or processor0/system + - the slave processor directories have no system directory and the + constant directory only contains the mesh. + - start the job in distributed mode by specifying the slave roots + (so one less than the number of processors) with + the -roots command line option: + + mpirun -np 2 icoFoam -roots '("/tmp")' -parallel + + - the alternative to the -roots option is to have a + cavity/system/decomposeParDict on the master with + distributed yes; + roots ("/tmp"); + + +Details: +- timeStampMaster, inotifyMaster : this works only for IOdictionaries that +are READ_IF_MODIFIED. It means that slaves read exactly the same dictionary +as the master so cannot be used for dictionaries that contain e.g. mesh +specific information. + +- inotify is a monitoring framework used to monitor changes in +lots of files (e.g. used in desktop searched like beagle). You specify +files to monitor and then get warned for any changes to these files. +It does not need timestamps. There is no need for fileModificationSkew to allow for time differences. (there can still temporarily be a difference -in modified status between different processors due to nfs lagging) - +in modified status between different processors due to nfs lagging). The big +problem is that it does not work over nfs3 (not sure about nfs4). - fileMonitor stores two hashtables per file so there is a small overhead adding and removing files from monitoring. - - if runTimeModifiable is false at start of run no files will get monitored, however if runTimeModified gets set to false during the run the files will still get monitored (though never reloaded). This is only a hypothetical @@ -46,7 +88,6 @@ problem in that the kernel still stores events for the monitored files. However inotify is very efficient - e.g. it gets used to track changes on file systems for desktop search engines. - - in the old system one could call modified() on any object and get and uptodate state. In the new system it will return the state from the last runTime++ (which if it triggered any re-reads will have reset the diff --git a/etc/controlDict b/etc/controlDict index f989950f26..b7beefbcd3 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -872,6 +872,14 @@ InfoSwitches OptimisationSwitches { fileModificationSkew 10; + + //- Modification checking: + // - timeStamp : use modification time on file + // - inotify : use inotify framework + // - timeStampMaster : do time stamp (and file reading) only on master. + // - inotifyMaster : do inotify (and file reading) only on master. + fileModificationChecking timeStampMaster;//inotify;timeStamp;inotifyMaster; + commsType nonBlocking; //scheduled; //blocking; floatTransfer 0; nProcsSimpleSum 0; diff --git a/src/OSspecific/POSIX/Allwmake b/src/OSspecific/POSIX/Allwmake index d3b21b47fc..e8260fff31 100755 --- a/src/OSspecific/POSIX/Allwmake +++ b/src/OSspecific/POSIX/Allwmake @@ -12,9 +12,9 @@ unset COMP_FLAGS LINK_FLAGS if [ -f /usr/include/sys/inotify.h -a "${1%USE_STAT}" = "$1" ] then echo "Found -- using inotify for file monitoring." - unset COMP_FLAGS + export COMP_FLAGS="-DFOAM_USE_INOTIFY" else - export COMP_FLAGS="-DFOAM_USE_STAT" + unset COMP_FLAGS fi diff --git a/src/OSspecific/POSIX/fileMonitor.C b/src/OSspecific/POSIX/fileMonitor.C index c7e590d6e5..069ef6de93 100644 --- a/src/OSspecific/POSIX/fileMonitor.C +++ b/src/OSspecific/POSIX/fileMonitor.C @@ -32,17 +32,17 @@ Class #include "PackedList.H" #include "PstreamReduceOps.H" #include "OSspecific.H" +#include "regIOobject.H" // for fileModificationSkew symbol -#ifdef FOAM_USE_STAT -# include "OSspecific.H" -# include "regIOobject.H" // for fileModificationSkew symbol -#else +#ifdef FOAM_USE_INOTIFY # include # include # include # define EVENT_SIZE ( sizeof (struct inotify_event) ) # define EVENT_LEN (EVENT_SIZE + 16) # define EVENT_BUF_LEN ( 1024 * EVENT_LEN ) +#else +# include "OSspecific.H" #endif // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -111,78 +111,77 @@ namespace Foam { public: -#ifdef FOAM_USE_STAT - //- From watch descriptor to modified time - DynamicList lastMod_; + const bool useInotify_; - //- initialize HashTable size - inline fileMonitorWatcher(const label sz = 20) - : - lastMod_(sz) - {} + // For inotify - inline bool addWatch(const label watchFd, const fileName& fName) - { - if (watchFd < lastMod_.size() && lastMod_[watchFd] != 0) - { - // Reuse of watchFd : should have lastMod set to 0. - FatalErrorIn("addWatch(const label, const fileName&)") - << "Problem adding watch " << watchFd - << " to file " << fName - << abort(FatalError); - } + //- File descriptor for the inotify instance + int inotifyFd_; - lastMod_(watchFd) = lastModified(fName); - return true; - } + //- Current watchIDs and corresponding directory id + DynamicList