diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H index 61c3da9bb9..a0b52f63d1 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H @@ -686,8 +686,14 @@ public: // Useful derived info - //- Is the point in the cell bounding box - bool pointInCellBB(const point& p, label celli) const; + //- Is the point in the cell bounding box, option relative + // tolerance to increase the effective size of the boundBox + bool pointInCellBB + ( + const point& p, + label celli, + scalar tol = 0 + ) const; //- Is the point in the cell bool pointInCell(const point& p, label celli) const; diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C index fecbc3c6fb..228097654c 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C @@ -30,16 +30,33 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // Is the point in the cell bounding box -bool Foam::primitiveMesh::pointInCellBB(const point& p, label celli) const +bool Foam::primitiveMesh::pointInCellBB +( + const point& p, + label celli, + scalar tol +) const { - return boundBox + boundBox bb ( cells()[celli].points ( faces(), points() - ) - ).contains(p); + ), + false + ); + + if (tol > SMALL) + { + bb = boundBox + ( + bb.min() - tol*bb.span(), + bb.max() + tol*bb.span() + ); + } + + return bb.contains(p); } diff --git a/src/lagrangian/basic/Particle/ParticleI.H b/src/lagrangian/basic/Particle/ParticleI.H index 35d658d115..50c727fe4a 100644 --- a/src/lagrangian/basic/Particle/ParticleI.H +++ b/src/lagrangian/basic/Particle/ParticleI.H @@ -970,11 +970,12 @@ inline void Foam::Particle::initCellFacePt() // number, but hasn't been able to find a cell to // occupy. - if(!cloud_.polyMesh_.pointInCellBB(position_, oldCellI)) + if(!cloud_.polyMesh_.pointInCellBB(position_, oldCellI, 0.1)) { - // If the position is not inside the bound-box of - // the cell that it thought it should be in, then - // this is considered an error. + // If the position is not inside the (slightly + // extended) bound-box of the cell that it thought + // it should be in, then this is considered an + // error. FatalErrorIn ( @@ -985,18 +986,20 @@ inline void Foam::Particle::initCellFacePt() ")" ) << "cell, tetFace and tetPt search failure at position " << position_ << nl + << "for requested cell " << oldCellI << nl << abort(FatalError); } - // The position is in the bound-box of the cell. This - // situation may arise because the face decomposition - // of the cell is not the same as when the particle - // acquired the cell index. For example, it has been - // read into a mesh that has made a different face - // base-point decision for a boundary face and now - // this particle is in a position that is not in the - // mesh. Gradually move the particle towards the - // centre of the cell that it thought that it was in. + // The position is in the (slightly extended) + // bound-box of the cell. This situation may arise + // because the face decomposition of the cell is not + // the same as when the particle acquired the cell + // index. For example, it has been read into a mesh + // that has made a different face base-point decision + // for a boundary face and now this particle is in a + // position that is not in the mesh. Gradually move + // the particle towards the centre of the cell that it + // thought that it was in. cellI_ = oldCellI; diff --git a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C index ef50886ebf..da5f1ce1dd 100644 --- a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C +++ b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C @@ -1108,7 +1108,7 @@ Foam::moleculeCloud::moleculeCloud mesh_(mesh), pot_(pot), cellOccupancy_(mesh_.nCells()), - il_(mesh_, pot_.pairPotentials().rCutMax(), true), + il_(mesh_, pot_.pairPotentials().rCutMax(), false), constPropList_(), rndGen_(clock::getTime()) { diff --git a/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allclean b/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allclean index 2bdc236211..38adb1cefa 100755 --- a/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allclean +++ b/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allclean @@ -5,6 +5,6 @@ cd ${0%/*} || exit 1 # run from this directory . $WM_PROJECT_DIR/bin/tools/CleanFunctions cleanCase -rm -rf 0/lagrangian 0/dsmcSigmaTcRMax +rm -rf 0/lagrangian 0/dsmcSigmaTcRMax 0/uniform > /dev/null 2>&1 # ----------------------------------------------------------------- end-of-file diff --git a/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/constant/polyMesh/blockMeshDict b/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/constant/polyMesh/blockMeshDict index 219238e7f9..9ecb2ad4ad 100644 --- a/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/constant/polyMesh/blockMeshDict +++ b/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/constant/polyMesh/blockMeshDict @@ -34,29 +34,50 @@ blocks hex (0 1 2 3 4 5 6 7) (20 16 16) simpleGrading (1 1 1) ); -patches +boundary ( - cyclic - xPeriodic - ( - (1 2 6 5) - (0 4 7 3) - ) + xPeriodic_half0 + { + type cyclic; + faces ((1 2 6 5)); + neighbourPatch xPeriodic_half1; + } - cyclic - yPeriodic - ( - (2 3 7 6) - (0 1 5 4) - ) + xPeriodic_half1 + { + type cyclic; + faces ((0 4 7 3)); + neighbourPatch xPeriodic_half0; + } - cyclic - zPeriodic - ( - (4 5 6 7) - (0 3 2 1) - ) -) + yPeriodic_half0 + { + type cyclic; + faces ((2 3 7 6)); + neighbourPatch yPeriodic_half1; + } + + yPeriodic_half1 + { + type cyclic; + faces ((0 1 5 4)); + neighbourPatch yPeriodic_half0; + } + + zPeriodic_half0 + { + type cyclic; + faces ((4 5 6 7)); + neighbourPatch zPeriodic_half1; + } + + zPeriodic_half1 + { + type cyclic; + faces ((0 3 2 1)); + neighbourPatch zPeriodic_half0; + } +); mergePatchPairs ( diff --git a/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allclean b/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allclean index 2bdc236211..38adb1cefa 100755 --- a/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allclean +++ b/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allclean @@ -5,6 +5,6 @@ cd ${0%/*} || exit 1 # run from this directory . $WM_PROJECT_DIR/bin/tools/CleanFunctions cleanCase -rm -rf 0/lagrangian 0/dsmcSigmaTcRMax +rm -rf 0/lagrangian 0/dsmcSigmaTcRMax 0/uniform > /dev/null 2>&1 # ----------------------------------------------------------------- end-of-file diff --git a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allclean b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allclean index 2bdc236211..38adb1cefa 100755 --- a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allclean +++ b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allclean @@ -5,6 +5,6 @@ cd ${0%/*} || exit 1 # run from this directory . $WM_PROJECT_DIR/bin/tools/CleanFunctions cleanCase -rm -rf 0/lagrangian 0/dsmcSigmaTcRMax +rm -rf 0/lagrangian 0/dsmcSigmaTcRMax 0/uniform > /dev/null 2>&1 # ----------------------------------------------------------------- end-of-file diff --git a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allclean b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allclean index 2bdc236211..38adb1cefa 100755 --- a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allclean +++ b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allclean @@ -5,6 +5,6 @@ cd ${0%/*} || exit 1 # run from this directory . $WM_PROJECT_DIR/bin/tools/CleanFunctions cleanCase -rm -rf 0/lagrangian 0/dsmcSigmaTcRMax +rm -rf 0/lagrangian 0/dsmcSigmaTcRMax 0/uniform > /dev/null 2>&1 # ----------------------------------------------------------------- end-of-file diff --git a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/Allclean b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/Allclean index 5af6a2bb22..5306205a8b 100755 --- a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/Allclean +++ b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/Allclean @@ -7,7 +7,7 @@ cd ${0%/*} || exit 1 # run from this directory ( cd periodicCubeArgon || exit - rm -rf 0/* + rm -rf 0/lagrangian 0/uniform rm -f Ar-Ar rm -f electrostatic rm -f constant/idList @@ -19,7 +19,7 @@ cd ${0%/*} || exit 1 # run from this directory ( cd periodicCubeWater || exit - rm -rf 0/* + rm -rf 0/lagrangian 0/uniform rm -f O-O rm -f electrostatic rm -f constant/idList diff --git a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/0/U b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/0/U new file mode 100644 index 0000000000..c93ca94b21 --- /dev/null +++ b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/0/U @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 1 -1 0 0 0 0 ]; + +internalField uniform ( 0 0 0 ); + +boundaryField +{ + periodicX_half0 + { + type cyclic; + } + periodicY_half0 + { + type cyclic; + } + periodicZ_half0 + { + type cyclic; + } + periodicY_half1 + { + type cyclic; + } + periodicZ_half1 + { + type cyclic; + } + periodicX_half1 + { + type cyclic; + } +} + + +// ************************************************************************* // diff --git a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/constant/polyMesh/blockMeshDict b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/constant/polyMesh/blockMeshDict index 0846dec79a..789934700a 100644 --- a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/constant/polyMesh/blockMeshDict +++ b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/constant/polyMesh/blockMeshDict @@ -34,29 +34,50 @@ blocks hex (0 1 2 3 4 5 6 7) liquid (12 12 12) simpleGrading (1 1 1) ); -patches +boundary ( - cyclic - periodicX - ( - (1 2 6 5) - (0 4 7 3) - ) + periodicX_half0 + { + type cyclic; + faces ((1 2 6 5)); + neighbourPatch periodicX_half1; + } - cyclic - periodicY - ( - (2 3 7 6) - (0 1 5 4) - ) + periodicX_half1 + { + type cyclic; + faces ((0 4 7 3)); + neighbourPatch periodicX_half0; + } - cyclic - periodicZ - ( - (0 3 2 1) - (4 5 6 7) - ) -) + periodicY_half0 + { + type cyclic; + faces ((2 3 7 6)); + neighbourPatch periodicY_half1; + } + + periodicY_half1 + { + type cyclic; + faces ((0 1 5 4)); + neighbourPatch periodicY_half0; + } + + periodicZ_half0 + { + type cyclic; + faces ((4 5 6 7)); + neighbourPatch periodicZ_half1; + } + + periodicZ_half1 + { + type cyclic; + faces ((0 3 2 1)); + neighbourPatch periodicZ_half0; + } +); mergePatchPairs ( diff --git a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/system/controlDict b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/system/controlDict index c2723fa60f..e2233c88c2 100644 --- a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/system/controlDict +++ b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/system/controlDict @@ -22,7 +22,7 @@ startTime 0; stopAt endTime; -endTime 1e-10; +endTime 5e-11; deltaT 1e-14; diff --git a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/0/U b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/0/U new file mode 100644 index 0000000000..c93ca94b21 --- /dev/null +++ b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/0/U @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 1 -1 0 0 0 0 ]; + +internalField uniform ( 0 0 0 ); + +boundaryField +{ + periodicX_half0 + { + type cyclic; + } + periodicY_half0 + { + type cyclic; + } + periodicZ_half0 + { + type cyclic; + } + periodicY_half1 + { + type cyclic; + } + periodicZ_half1 + { + type cyclic; + } + periodicX_half1 + { + type cyclic; + } +} + + +// ************************************************************************* // diff --git a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/constant/polyMesh/blockMeshDict b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/constant/polyMesh/blockMeshDict index 790a0f4fe5..1d301a3638 100644 --- a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/constant/polyMesh/blockMeshDict +++ b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/constant/polyMesh/blockMeshDict @@ -34,29 +34,50 @@ blocks hex (0 1 2 3 4 5 6 7) liquid (12 12 11) simpleGrading (1 1 1) ); -patches +boundary ( - cyclic - periodicX - ( - (1 2 6 5) - (0 4 7 3) - ) + periodicX_half0 + { + type cyclic; + faces ((1 2 6 5)); + neighbourPatch periodicX_half1; + } - cyclic - periodicY - ( - (2 3 7 6) - (0 1 5 4) - ) + periodicX_half1 + { + type cyclic; + faces ((0 4 7 3)); + neighbourPatch periodicX_half0; + } - cyclic - periodicZ - ( - (0 3 2 1) - (4 5 6 7) - ) -) + periodicY_half0 + { + type cyclic; + faces ((2 3 7 6)); + neighbourPatch periodicY_half1; + } + + periodicY_half1 + { + type cyclic; + faces ((0 1 5 4)); + neighbourPatch periodicY_half0; + } + + periodicZ_half0 + { + type cyclic; + faces ((4 5 6 7)); + neighbourPatch periodicZ_half1; + } + + periodicZ_half1 + { + type cyclic; + faces ((0 3 2 1)); + neighbourPatch periodicZ_half0; + } +); mergePatchPairs ( diff --git a/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/system/controlDict b/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/system/controlDict index abf063b4f2..a9a721bbce 100644 --- a/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/system/controlDict +++ b/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/system/controlDict @@ -22,13 +22,13 @@ startTime 0; stopAt endTime; -endTime 5e-12; +endTime 2e-13; deltaT 1e-15; writeControl runTime; -writeInterval 2e-13; +writeInterval 5e-14; purgeWrite 0;