diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoLTSPimpleFoam/Make/options b/applications/solvers/compressible/rhoPimpleFoam/rhoLTSPimpleFoam/Make/options index 11053f31a9..502938c53c 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/rhoLTSPimpleFoam/Make/options +++ b/applications/solvers/compressible/rhoPimpleFoam/rhoLTSPimpleFoam/Make/options @@ -1,5 +1,4 @@ EXE_INC = \ - -I../rhoPorousMRFPimpleFoam \ -I.. \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \ diff --git a/applications/solvers/lagrangian/reactingParcelFilmFoam/reactingParcelFilmFoam.C b/applications/solvers/lagrangian/reactingParcelFilmFoam/reactingParcelFilmFoam.C index 65cfcb4516..4067c125eb 100644 --- a/applications/solvers/lagrangian/reactingParcelFilmFoam/reactingParcelFilmFoam.C +++ b/applications/solvers/lagrangian/reactingParcelFilmFoam/reactingParcelFilmFoam.C @@ -104,13 +104,9 @@ int main(int argc, char *argv[]) } rho = thermo.rho(); + } - runTime.write(); - } - else - { - runTime.write(); - } + runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" diff --git a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C index 44a02e234a..2a958b3a3c 100644 --- a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C +++ b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C @@ -269,9 +269,10 @@ void selectCurvatureCells querySurf.surface(), querySurf, pointField(1, mesh.cellCentres()[0]), - false, - false, - false, + false, // includeCut + false, // includeInside + false, // includeOutside + false, // geometricOnly nearDist, curvature ); diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/Make/files b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/Make/files index e42c52451f..bc4a363517 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/Make/files +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/Make/files @@ -64,6 +64,7 @@ initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C initialPointsMethod/faceCentredCubic/faceCentredCubic.C initialPointsMethod/pointFile/pointFile.C initialPointsMethod/autoDensity/autoDensity.C +initialPointsMethod/rayShooting/rayShooting.C relaxationModel/relaxationModel/relaxationModel.C relaxationModel/adaptiveLinear/adaptiveLinear.C diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 6f137249c1..e580febdd8 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -1249,7 +1249,7 @@ void Foam::conformalVoronoiMesh::move() if ( ( - (vA->internalPoint() && vB->internalPoint()) + (vA->internalPoint() || vB->internalPoint()) && (!vA->referred() || !vB->referred()) // || // ( diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C index 20a8b278eb..0360cf0d83 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C @@ -670,6 +670,32 @@ Foam::Field Foam::conformationSurfaces::wellInOutSide continue; } + const searchableSurface& surface(allGeometry_[surfaces_[s]]); + + if (!surface.hasVolumeType()) + { + pointField sample(1, samplePts[i]); + scalarField nearestDistSqr(1, GREAT); + List info; + + surface.findNearest(sample, nearestDistSqr, info); + + vector hitDir = info[0].rawPoint() - samplePts[i]; + hitDir /= mag(hitDir) + SMALL; + + if + ( + findSurfaceAnyIntersection + ( + samplePts[i], + info[0].rawPoint() - 1e-3*mag(hitDir)*(hitDir) + ) + ) + { + continue; + } + } + if (surfaceVolumeTests[s][i] == volumeType::OUTSIDE) { if @@ -694,44 +720,6 @@ Foam::Field Foam::conformationSurfaces::wellInOutSide break; } } -// else -// { -// // Surface volume type is unknown -// Info<< "UNKNOWN" << endl; -// // Get nearest face normal -// -// pointField sample(1, samplePts[i]); -// scalarField nearestDistSqr(1, GREAT); -// List info; -// vectorField norms(1); -// -// surface.findNearest(sample, nearestDistSqr, info); -// surface.getNormal(info, norms); -// -// vector fN = norms[0]; -// fN /= mag(fN); -// -// vector hitDir = info[0].rawPoint() - samplePts[i]; -// hitDir /= mag(hitDir); -// -// if ((fN & hitDir) < 0) -// { -// // Point is OUTSIDE -// -// if -// ( -// normalVolumeTypes_[regionI] -// == extendedFeatureEdgeMesh::OUTSIDE -// ) -// { -// } -// else -// { -// insidePoint[i] = false; -// break; -// } -// } -// } } } diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C new file mode 100644 index 0000000000..ebecad88e1 --- /dev/null +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C @@ -0,0 +1,218 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 . + +\*---------------------------------------------------------------------------*/ + +#include "rayShooting.H" +#include "addToRunTimeSelectionTable.H" +#include "triSurfaceMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(rayShooting, 0); +addToRunTimeSelectionTable(initialPointsMethod, rayShooting, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +rayShooting::rayShooting +( + const dictionary& initialPointsDict, + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr& decomposition +) +: + initialPointsMethod + ( + typeName, + initialPointsDict, + runTime, + rndGen, + geometryToConformTo, + cellShapeControls, + decomposition + ), + randomiseInitialGrid_(detailsDict().lookup("randomiseInitialGrid")), + randomPerturbationCoeff_ + ( + readScalar(detailsDict().lookup("randomPerturbationCoeff")) + ) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +List rayShooting::initialPoints() const +{ + // Loop over surface faces + const searchableSurfaces& surfaces = geometryToConformTo().geometry(); + const labelList& surfacesToConformTo = geometryToConformTo().surfaces(); + + const scalar maxRayLength = surfaces.bounds().mag(); + + // Initialise points list + label initialPointsSize = 0; + forAll(surfaces, surfI) + { + initialPointsSize += surfaces[surfI].size(); + } + + DynamicList initialPoints(initialPointsSize); + + forAll(surfacesToConformTo, surfI) + { + const searchableSurface& s = surfaces[surfacesToConformTo[surfI]]; + + tmp faceCentresTmp(s.coordinates()); + const pointField& faceCentres = faceCentresTmp(); + + Info<< " Shoot rays from " << s.name() << nl + << " nRays = " << faceCentres.size() << endl; + + + forAll(faceCentres, fcI) + { + const Foam::point& fC = faceCentres[fcI]; + + if + ( + Pstream::parRun() + && !decomposition().positionOnThisProcessor(fC) + ) + { + continue; + } + + const scalar pert = + randomPerturbationCoeff_ + *cellShapeControls().cellSize(fC); + + pointIndexHit surfHitStart; + label hitSurfaceStart; + + // Face centres should be on the surface so search distance can be + // small + geometryToConformTo().findSurfaceNearest + ( + fC, + sqr(pert), + surfHitStart, + hitSurfaceStart + ); + + vectorField normStart(1, vector::min); + geometryToConformTo().getNormal + ( + hitSurfaceStart, + List(1, surfHitStart), + normStart + ); + + pointIndexHit surfHitEnd; + label hitSurfaceEnd; + + geometryToConformTo().findSurfaceNearestIntersection + ( + fC - normStart[0]*pert, + fC - normStart[0]*maxRayLength, + surfHitEnd, + hitSurfaceEnd + ); + + if (surfHitEnd.hit()) + { + vectorField normEnd(1, vector::min); + geometryToConformTo().getNormal + ( + hitSurfaceEnd, + List(1, surfHitEnd), + normEnd + ); + + if ((normStart[0] & normEnd[0]) < 0) + { + line l(fC, surfHitEnd.hitPoint()); + + if (Pstream::parRun()) + { + // Clip the line in parallel + pointIndexHit procIntersection = + decomposition().findLine + ( + l.start(), + l.end() + ); + + if (procIntersection.hit()) + { + l = + line + ( + l.start(), + procIntersection.hitPoint() + ); + } + } + + Foam::point midPoint(l.centre()); + + const scalar minDistFromSurfaceSqr = + minimumSurfaceDistanceCoeffSqr_ + *sqr(cellShapeControls().cellSize(midPoint)); + + if (randomiseInitialGrid_) + { + midPoint.x() += pert*(rndGen().scalar01() - 0.5); + midPoint.y() += pert*(rndGen().scalar01() - 0.5); + midPoint.z() += pert*(rndGen().scalar01() - 0.5); + } + + if + ( + magSqr(midPoint - l.start()) > minDistFromSurfaceSqr + && magSqr(midPoint - l.end()) > minDistFromSurfaceSqr + ) + { + initialPoints.append(toPoint(midPoint)); + } + } + } + } + } + + return initialPoints.shrink(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.H new file mode 100644 index 0000000000..e66df62b7c --- /dev/null +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.H @@ -0,0 +1,103 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 . + +Class + Foam::rayShooting + +Description + +SourceFiles + rayShooting.C + +\*---------------------------------------------------------------------------*/ + +#ifndef rayShooting_H +#define rayShooting_H + +#include "initialPointsMethod.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class rayShooting Declaration +\*---------------------------------------------------------------------------*/ + +class rayShooting +: + public initialPointsMethod +{ + +private: + + // Private data + + //- Should the initial positions be randomised + Switch randomiseInitialGrid_; + + //- Randomise the initial positions by fraction of the initialCellSize_ + scalar randomPerturbationCoeff_; + + +public: + + //- Runtime type information + TypeName("rayShooting"); + + // Constructors + + //- Construct from components + rayShooting + ( + const dictionary& initialPointsDict, + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr& decomposition + ); + + + //- Destructor + virtual ~rayShooting() + {} + + + // Member Functions + + //- Return the initial points for the conformalVoronoiMesh + virtual List initialPoints() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSetDict b/applications/utilities/mesh/manipulation/topoSet/topoSetDict index 11dccf942b..9dee4d1df9 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSetDict +++ b/applications/utilities/mesh/manipulation/topoSet/topoSetDict @@ -143,6 +143,9 @@ FoamFile // sourceInfo // { // file "www.avl.com-geometry.stl"; +// useSurfaceOrientation false; // use closed surface inside/outside +// // test (ignores includeCut, +// // outsidePoints) // outsidePoints ((-99 -99 -59)); // definition of outside // includeCut false; // cells cut by surface // includeInside false; // cells not on outside of surf diff --git a/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C b/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C index 5a6fad75a6..4d2ab943ac 100644 --- a/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C +++ b/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.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 @@ -184,6 +184,7 @@ int main(int argc, char *argv[]) } } + if (nTracks == 0) { Info<< "\n No track data" << endl; @@ -202,11 +203,13 @@ int main(int argc, char *argv[]) // particle "age" property used to sort the tracks List > agePerTrack(nTracks); + List > particleMap(nTracks); forAll(trackLengths, i) { const label length = trackLengths[i]; agePerTrack[i].setSize(length); + particleMap[i].setSize(length); } // store the particle age per track @@ -228,6 +231,7 @@ int main(int argc, char *argv[]) const label trackI = particleToTrack[i]; const label sampleI = trackSamples[trackI]; agePerTrack[trackI][sampleI] = age[i]; + particleMap[trackI][sampleI] = i; trackSamples[trackI]++; } tage.clear(); @@ -251,21 +255,30 @@ int main(int argc, char *argv[]) Info<< "\n Writing points" << endl; { - label offset = 0; forAll(agePerTrack, i) { agePerTrack[i].sort(); + const labelList& ids = agePerTrack[i].indices(); + labelList& particleIds = particleMap[i]; + + { + // update addressing + List