Merge remote-tracking branch 'origin/develop' into feature-shortestPathSet

This commit is contained in:
mattijs
2017-10-09 10:18:15 +01:00
1382 changed files with 36253 additions and 14549 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
@ -214,6 +214,8 @@ Foam::label Foam::probes::prepare()
{
probeDir = mesh_.time().path()/probeSubDir;
}
// Remove ".."
probeDir.clean();
// ignore known fields, close streams for fields that no longer exist
forAllIter(HashPtrTable<OFstream>, probeFilePtrs_, iter)

View File

@ -54,15 +54,17 @@ bool Foam::faceOnlySet::trackToBoundary
DynamicList<scalar>& samplingCurveDist
) const
{
particle::TrackingData<passiveParticleCloud> trackData(particleCloud);
particle::trackingData td(particleCloud);
const point& trackPt = singleParticle.position();
point trackPt = singleParticle.position();
while(true)
{
point oldPoint = trackPt;
singleParticle.trackToFace(end_, trackData);
singleParticle.trackToAndHitFace(end_ - start_, 0, particleCloud, td);
trackPt = singleParticle.position();
if (singleParticle.face() != -1 && mag(oldPoint - trackPt) > smallDist)
{
@ -78,7 +80,7 @@ bool Foam::faceOnlySet::trackToBoundary
// End reached
return false;
}
else if (singleParticle.onBoundary())
else if (singleParticle.onBoundaryFace())
{
// Boundary reached
return true;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -54,31 +54,16 @@ bool Foam::polyLineSet::trackToBoundary
DynamicList<scalar>& samplingCurveDist
) const
{
particle::TrackingData<passiveParticleCloud> trackData(particleCloud);
// Alias
const point& trackPt = singleParticle.position();
while (true)
{
// Local geometry info
const vector offset = sampleCoords_[sampleI+1] - sampleCoords_[sampleI];
const scalar smallDist = mag(tol*offset);
point oldPos = trackPt;
label facei = -1;
do
{
singleParticle.stepFraction() = 0;
singleParticle.track(sampleCoords_[sampleI+1], trackData);
}
while
(
!singleParticle.onBoundary()
&& (mag(trackPt - oldPos) < smallDist)
);
singleParticle.track(offset, 0);
const point trackPt = singleParticle.position();
if (singleParticle.onBoundary())
if (singleParticle.onBoundaryFace())
{
//Info<< "trackToBoundary : reached boundary"
// << " trackPt:" << trackPt << endl;
@ -94,7 +79,7 @@ bool Foam::polyLineSet::trackToBoundary
// << endl;
samplingPts.append(trackPt);
samplingCells.append(singleParticle.cell());
samplingFaces.append(facei);
samplingFaces.append(singleParticle.face());
// trackPt is at sampleI+1
samplingCurveDist.append(1.0*(sampleI+1));

View File

@ -210,17 +210,25 @@ Foam::point Foam::sampledSet::pushIn
label tetPtI;
mesh().findTetFacePt(celli, facePt, tetFacei, tetPtI);
// This is the tolerance that was defined as a static constant of the
// particle class. It is no longer used by particle, following the switch to
// barycentric tracking. The only place in which the tolerance is now used
// is here. I'm not sure what the purpose of this code is, but it probably
// wants removing. It is doing tet-searches for a particle position. This
// should almost certainly be left to the particle class.
const scalar trackingCorrectionTol = 1e-5;
if (tetFacei == -1 || tetPtI == -1)
{
newPosition = facePt;
label trap(1.0/particle::trackingCorrectionTol + 1);
label trap(1.0/trackingCorrectionTol + 1);
label iterNo = 0;
do
{
newPosition += particle::trackingCorrectionTol*(cC - facePt);
newPosition += trackingCorrectionTol*(cC - facePt);
mesh().findTetFacePt
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
@ -109,6 +109,8 @@ Foam::sampledSets::sampledSets
{
outputPath_ = outputPath_/mesh_.name();
}
// Remove ".."
outputPath_.clean();
read(dict);
}
@ -143,6 +145,8 @@ Foam::sampledSets::sampledSets
{
outputPath_ = outputPath_/mesh_.name();
}
// Remove ".."
outputPath_.clean();
read(dict);
}

View File

@ -94,10 +94,7 @@ bool Foam::uniformSet::trackToBoundary
const vector smallVec = tol*offset;
const scalar smallDist = mag(smallVec);
// Alias
const point& trackPt = singleParticle.position();
particle::TrackingData<passiveParticleCloud> trackData(particleCloud);
point trackPt = singleParticle.position();
while(true)
{
@ -153,32 +150,10 @@ bool Foam::uniformSet::trackToBoundary
<< " to:" << samplePt << endl;
}
point oldPos = trackPt;
label facei = -1;
do
{
singleParticle.stepFraction() = 0;
singleParticle.track(samplePt, trackData);
singleParticle.track(samplePt - trackPt, 0);
trackPt = singleParticle.position();
if (debug)
{
Pout<< "Result of tracking "
<< " trackPt:" << trackPt
<< " trackCelli:" << singleParticle.cell()
<< " trackFacei:" << singleParticle.face()
<< " onBoundary:" << singleParticle.onBoundary()
<< " samplePt:" << samplePt
<< " smallDist:" << smallDist
<< endl;
}
}
while
(
!singleParticle.onBoundary()
&& (mag(trackPt - oldPos) < smallDist)
);
if (singleParticle.onBoundary())
if (singleParticle.onBoundaryFace())
{
//Pout<< "trackToBoundary : reached boundary" << endl;
if (mag(trackPt - samplePt) < smallDist)
@ -188,7 +163,7 @@ bool Foam::uniformSet::trackToBoundary
// Reached samplePt on boundary
samplingPts.append(trackPt);
samplingCells.append(singleParticle.cell());
samplingFaces.append(facei);
samplingFaces.append(singleParticle.face());
samplingCurveDist.append(mag(trackPt - start_));
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
@ -143,6 +143,8 @@ Foam::sampledSurfaces::sampledSurfaces
{
outputPath_ = mesh_.time().path()/"postProcessing"/name;
}
// Remove ".."
outputPath_.clean();
read(dict);
}
@ -176,6 +178,8 @@ Foam::sampledSurfaces::sampledSurfaces
{
outputPath_ = time_.path()/"postProcessing"/name;
}
// Remove ".."
outputPath_.clean();
read(dict);
}

View File

@ -683,7 +683,8 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
),
dict
),
sampleSource_(samplingSourceNames_.lookup("source", dict)),
needsUpdate_(true),
@ -779,15 +780,28 @@ bool Foam::sampledTriSurfaceMesh::update()
surface_.triSurface::meshPoints()
);
bb.intersect(mesh().bounds());
// Check for overlap with (global!) mesh bb
const bool intersect = bb.intersect(mesh().bounds());
// Extend a bit
const vector span(bb.span());
if (!intersect)
{
// Surface and mesh do not overlap at all. Guarantee a valid
// bounding box so we don't get any 'invalid bounding box' errors.
bb = treeBoundBox(mesh().bounds());
const vector span(bb.span());
bb.min() -= 0.5*span;
bb.max() += 0.5*span;
bb.min() += (0.5-1e-6)*span;
bb.max() -= (0.5-1e-6)*span;
}
else
{
// Extend a bit
const vector span(bb.span());
bb.min() -= 0.5*span;
bb.max() += 0.5*span;
bb.inflate(1e-6);
bb.inflate(1e-6);
}
// Mesh search engine, no triangulation of faces.
meshSearch meshSearcher(mesh(), bb, polyMesh::FACE_PLANES);

View File

@ -24,8 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "IOmanip.H"
#include "IFstream.H"
#include "OFstream.H"
#include "Fstream.H"
#include "OSspecific.H"
#include "ensightPartFaces.H"
#include "ensightSerialOutput.H"

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,10 +58,10 @@ void Foam::surfMeshSamplers::checkOutNames
{
objectRegistry& reg = const_cast<objectRegistry&>(registry);
forAll(names, namei)
for (const word& fldName : names)
{
objectRegistry::iterator iter = reg.find(names[namei]);
if (iter != reg.end())
objectRegistry::iterator iter = reg.find(fldName);
if (iter.found())
{
registry.checkOut(*iter());
}
@ -156,10 +156,8 @@ bool Foam::surfMeshSamplers::execute()
DynamicList<word> added(derivedNames_.size());
DynamicList<word> cleanup(derivedNames_.size());
forAll(derivedNames_, namei)
for (const word& derivedName : derivedNames_)
{
const word& derivedName = derivedNames_[namei];
if (derivedName == "rhoU")
{
added.append(derivedName);
@ -190,20 +188,48 @@ bool Foam::surfMeshSamplers::execute()
{
cleanup.append(derivedName);
db.store
(
new volScalarField
const volScalarField& p =
mesh_.lookupObject<volScalarField>("p");
if (p.dimensions() == dimPressure)
{
db.store
(
derivedName,
// pTotal = p + U^2 / 2
new volScalarField
(
mesh_.lookupObject<volScalarField>("p")
+ 0.5
* mesh_.lookupObject<volScalarField>("rho")
* magSqr(mesh_.lookupObject<volVectorField>("U"))
derivedName,
// pTotal = p + rho U^2 / 2
(
p
+ 0.5
* mesh_.lookupObject<volScalarField>("rho")
* magSqr
(
mesh_.lookupObject<volVectorField>("U")
)
)
)
)
);
);
}
else
{
db.store
(
new volScalarField
(
derivedName,
// pTotal = p + U^2 / 2
(
p
+ 0.5
* magSqr
(
mesh_.lookupObject<volVectorField>("U")
)
)
)
);
}
}
}
else
@ -226,10 +252,8 @@ bool Foam::surfMeshSamplers::execute()
const wordList fields = acceptable.sortedToc();
if (!fields.empty())
{
forAll(*this, surfI)
for (surfMeshSampler& s : surfaces())
{
surfMeshSampler& s = operator[](surfI);
// Potentially monitor the update for writing geometry?
if (s.needsUpdate())
{
@ -258,21 +282,20 @@ bool Foam::surfMeshSamplers::write()
wordReList select(fieldSelection_.size() + derivedNames_.size());
label nElem = 0;
forAll(fieldSelection_, i)
for (const auto& item : fieldSelection_)
{
select[nElem++] = fieldSelection_[i];
select[nElem++] = item;
}
forAll(derivedNames_, i)
for (const auto& derivedName : derivedNames_)
{
select[nElem++] = derivedNames_[i];
select[nElem++] = derivedName;
}
// avoid duplicate entries
select = wordRes::uniq(select);
forAll(*this, surfI)
for (const surfMeshSampler& s : surfaces())
{
const surfMeshSampler& s = operator[](surfI);
s.write(select);
}
@ -317,10 +340,8 @@ bool Foam::surfMeshSamplers::read(const dictionary& dict)
if (this->size())
{
Info<< "Reading surface description:" << nl;
forAll(*this, surfI)
for (surfMeshSampler& s : surfaces())
{
surfMeshSampler& s = operator[](surfI);
Info<< " " << s.name() << nl;
if (createOnRead)
{
@ -370,9 +391,9 @@ void Foam::surfMeshSamplers::readUpdate(const polyMesh::readUpdateState state)
bool Foam::surfMeshSamplers::needsUpdate() const
{
forAll(*this, surfI)
for (const surfMeshSampler& s : surfaces())
{
if (operator[](surfI).needsUpdate())
if (s.needsUpdate())
{
return true;
}
@ -386,9 +407,9 @@ bool Foam::surfMeshSamplers::expire()
{
bool justExpired = false;
forAll(*this, surfI)
for (surfMeshSampler& s : surfaces())
{
if (operator[](surfI).expire())
if (s.expire())
{
justExpired = true;
}
@ -407,9 +428,9 @@ bool Foam::surfMeshSamplers::update()
}
bool updated = false;
forAll(*this, surfI)
for (surfMeshSampler& s : surfaces())
{
if (operator[](surfI).update())
if (s.update())
{
updated = true;
}

View File

@ -134,6 +134,18 @@ class surfMeshSamplers
const UList<word>& names
);
//- Access the sampling surfaces
inline const PtrList<surfMeshSampler>& surfaces() const
{
return static_cast<const PtrList<surfMeshSampler>&>(*this);
}
//- Access the sampling surfaces
inline PtrList<surfMeshSampler>& surfaces()
{
return static_cast<PtrList<surfMeshSampler>&>(*this);
}
//- Filter acceptable fields types
template<class Type>

View File

@ -218,9 +218,9 @@ bool Foam::cuttingPlane::walkCell
{
WarningInFunction
<< "Did not find closed walk along surface of cell " << celli
<< " at " << mesh.cellCentres()[celli]
<< " starting from edge " << startEdgeI
<< " in " << nIter << " iterations." << nl
<< "Collected cutPoints so far:" << faceVerts
<< " in " << nIter << " iterations."
<< endl;
return false;
}

View File

@ -894,6 +894,9 @@ Foam::triSurface Foam::isoSurface::stitchTriPoints
// Check that enough merged.
if (debug)
{
Pout<< "isoSurface : merged from " << triPoints.size()
<< " down to " << newPoints.size() << " unique points." << endl;
pointField newNewPoints;
labelList oldToNew;
bool hasMerged = mergePoints
@ -1232,19 +1235,16 @@ void Foam::isoSurface::trimToBox
{
dynInterpolatedPoints.append(pointI);
FixedList<label, 3> oldPoints;
oldPoints[0] = 3*oldTriI;
oldPoints[1] = 3*oldTriI+1;
oldPoints[2] = 3*oldTriI+2;
FixedList<label, 3> oldPoints
(
{3*oldTriI, 3*oldTriI+1, 3*oldTriI+2}
);
dynInterpolatedOldPoints.append(oldPoints);
triPointRef tri(oldTriPoints, oldPoints);
FixedList<scalar, 3> bary;
tri.barycentric(pt, bary);
FixedList<scalar, 3> weights;
weights[0] = bary[0];
weights[1] = bary[1];
weights[2] = bary[2];
barycentric2D bary = tri.pointToBarycentric(pt);
FixedList<scalar, 3> weights({bary.a(), bary.b(), bary.c()});
dynInterpolationWeights.append(weights);
}
}