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

This commit is contained in:
mattijs
2018-03-15 10:03:22 +00:00
4030 changed files with 176487 additions and 63227 deletions

View File

@ -38,12 +38,7 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void makeGraph
void Foam::makeGraph
(
const scalarField& x,
const volScalarField& vsf,
@ -54,7 +49,7 @@ void makeGraph
}
void makeGraph
void Foam::makeGraph
(
const scalarField& x,
const volScalarField& vsf,
@ -76,7 +71,7 @@ void makeGraph
}
void makeGraph
void Foam::makeGraph
(
const scalarField& x,
const scalarField& sf,
@ -96,8 +91,4 @@ void makeGraph
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -5,12 +5,7 @@
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void writeCellGraph
void Foam::writeCellGraph
(
const volScalarField& vsf,
const word& graphFormat
@ -30,8 +25,4 @@ void writeCellGraph
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -3,15 +3,9 @@
#include "fvMesh.H"
#include "graph.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void writePatchGraph
void Foam::writePatchGraph
(
const volScalarField& vsf,
const label patchLabel,
@ -30,8 +24,4 @@ void writePatchGraph
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -56,19 +56,17 @@ bool Foam::cellVolumeWeightMethod::findInitialSeeds
const faceList& srcFaces = src_.faces();
const pointField& srcPts = src_.points();
for (label i = startSeedI; i < srcCellIDs.size(); i++)
for (label i = startSeedI; i < srcCellIDs.size(); ++i)
{
label srcI = srcCellIDs[i];
const label srcI = srcCellIDs[i];
if (mapFlag[srcI])
{
const pointField
pts(srcCells[srcI].points(srcFaces, srcPts).xfer());
const pointField pts(srcCells[srcI].points(srcFaces, srcPts));
forAll(pts, ptI)
for (const point& pt : pts)
{
const point& pt = pts[ptI];
label tgtI = tgt_.cellTree().findInside(pt);
const label tgtI = tgt_.cellTree().findInside(pt);
if (tgtI != -1 && intersect(srcI, tgtI))
{
@ -377,7 +375,7 @@ void Foam::cellVolumeWeightMethod::calculate
// list to keep track of whether src cell can be mapped
boolList mapFlag(src_.nCells(), false);
UIndirectList<bool>(mapFlag, srcCellIDs) = true;
boolUIndList(mapFlag, srcCellIDs) = true;
// find initial point in tgt mesh
label srcSeedI = -1;

View File

@ -245,7 +245,7 @@ void Foam::correctedCellVolumeWeightMethod::calculate
// list to keep track of whether src cell can be mapped
boolList mapFlag(src_.nCells(), false);
UIndirectList<bool>(mapFlag, srcCellIDs) = true;
boolUIndList(mapFlag, srcCellIDs) = true;
// find initial point in tgt mesh
label srcSeedI = -1;

View File

@ -266,7 +266,7 @@ void Foam::directMethod::calculate
// list to keep track of whether src cell can be mapped
boolList mapFlag(src_.nCells(), false);
UIndirectList<bool>(mapFlag, srcCellIDs) = true;
boolUIndList(mapFlag, srcCellIDs) = true;
// find initial point in tgt mesh
label srcSeedI = -1;

View File

@ -297,7 +297,7 @@ Foam::label Foam::mapNearestMethod::findMappedSrcCell
// search target tgtCelli neighbours for match with source cell
label tgtI = testCells.remove();
if (findIndex(visitedCells, tgtI) == -1)
if (!visitedCells.found(tgtI))
{
visitedCells.append(tgtI);
@ -311,7 +311,7 @@ Foam::label Foam::mapNearestMethod::findMappedSrcCell
forAll(nbrCells, i)
{
if (findIndex(visitedCells, nbrCells[i]) == -1)
if (!visitedCells.found(nbrCells[i]))
{
testCells.append(nbrCells[i]);
}
@ -373,7 +373,7 @@ void Foam::mapNearestMethod::calculate
// list to keep track of whether src cell can be mapped
boolList mapFlag(src_.nCells(), false);
UIndirectList<bool>(mapFlag, srcCellIDs) = true;
boolUIndList(mapFlag, srcCellIDs) = true;
// find initial point in tgt mesh
label srcSeedI = -1;

View File

@ -168,14 +168,12 @@ void Foam::meshToMeshMethod::appendNbrCells
const labelList& nbrCells = mesh.cellCells()[celli];
// filter out cells already visited from cell neighbours
forAll(nbrCells, i)
for (const label nbrCelli : nbrCells)
{
label nbrCelli = nbrCells[i];
if
(
(findIndex(visitedCells, nbrCelli) == -1)
&& (findIndex(nbrCellIDs, nbrCelli) == -1)
!visitedCells.found(nbrCelli)
&& !nbrCellIDs.found(nbrCelli)
)
{
nbrCellIDs.append(nbrCelli);

View File

@ -469,10 +469,10 @@ void Foam::meshToMesh::calculate(const word& methodName, const bool normalise)
tgtRegion_.time(),
IOobject::NO_READ
),
xferMove(newTgtPoints),
xferMove(newTgtFaces),
xferMove(newTgtFaceOwners),
xferMove(newTgtFaceNeighbours),
std::move(newTgtPoints),
std::move(newTgtFaces),
std::move(newTgtFaceOwners),
std::move(newTgtFaceNeighbours),
false // no parallel comms
);

View File

@ -70,7 +70,7 @@ Foam::label Foam::meshToMesh::calcDistribution
}
else if (nHaveCells == 1)
{
proci = findIndex(cellsPresentOnProc, 1);
proci = cellsPresentOnProc.find(1);
if (debug)
{
InfoInFunction
@ -246,17 +246,12 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
}
}
autoPtr<mapDistribute> mapPtr
return autoPtr<mapDistribute>::New
(
new mapDistribute
(
segmentI, // size after construction
sendMap.xfer(),
constructMap.xfer()
)
segmentI, // size after construction
std::move(sendMap),
std::move(constructMap)
);
return mapPtr;
}

View File

@ -38,8 +38,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef meshtoMesh_H
#define meshtoMesh_H
#ifndef meshToMesh0_H
#define meshToMesh0_H
#include "fvMesh.H"
#include "HashTable.H"

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -238,11 +238,7 @@ Foam::patchProbes::patchProbes
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::patchProbes::~patchProbes()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::patchProbes::write()
{
@ -269,9 +265,10 @@ bool Foam::patchProbes::read(const dictionary& dict)
{
if (!dict.readIfPresent("patches", patchNames_))
{
word patchName(dict.lookup("patch"));
patchNames_ = wordReList(1, wordRe(patchName));
patchNames_.setSize(1);
patchNames_[0] = wordRe(word(dict.lookup("patch")));
}
return probes::read(dict);
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -96,7 +96,7 @@ protected:
// Protected data
//- Patches to sample
wordReList patchNames_;
wordRes patchNames_;
// Protected Member Functions
@ -173,7 +173,7 @@ public:
);
//- Destructor
virtual ~patchProbes();
virtual ~patchProbes() = default;
//- Public members

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -313,11 +313,6 @@ Foam::probes::probes
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::probes::~probes()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,7 +85,7 @@ SourceFiles
#include "volFieldsFwd.H"
#include "surfaceFieldsFwd.H"
#include "surfaceMesh.H"
#include "wordReList.H"
#include "wordRes.H"
using namespace Foam::functionObjects;
@ -141,7 +141,7 @@ protected:
// Read from dictonary
//- Names of fields to probe
wordReList fieldSelection_;
wordRes fieldSelection_;
//- Fixed locations, default = yes
// Note: set to false for moving mesh calculations where locations
@ -254,13 +254,13 @@ public:
//- Destructor
virtual ~probes();
virtual ~probes() = default;
// Member Functions
//- Return names of fields to probe
virtual const wordReList& fieldNames() const
virtual const wordRes& fieldNames() const
{
return fieldSelection_;
}

View File

@ -54,6 +54,8 @@ bool Foam::faceOnlySet::trackToBoundary
DynamicList<scalar>& samplingCurveDist
) const
{
const vector offset = (end_ - start_);
particle::trackingData td(particleCloud);
point trackPt = singleParticle.position();
@ -75,9 +77,10 @@ bool Foam::faceOnlySet::trackToBoundary
samplingCurveDist.append(mag(trackPt - start_));
}
if (mag(trackPt - end_) < smallDist)
if (-smallDist < ((trackPt - end_) & offset))
{
// End reached
// Projected onto sampling vector
// - done when we are near or past the end of the sampling vector
return false;
}
else if (singleParticle.onBoundaryFace())
@ -166,7 +169,6 @@ void Foam::faceOnlySet::calcSamples
// Set points and cell/face labels to empty lists
//Info<< "calcSamples : Both start_ and end_ outside domain"
// << endl;
const_cast<polyMesh&>(mesh()).moving(oldMoving);
const_cast<polyMesh&>(mesh()).moving(oldMoving);
return;

View File

@ -314,10 +314,4 @@ Foam::patchCloudSet::patchCloudSet
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::patchCloudSet::~patchCloudSet()
{}
// ************************************************************************* //

View File

@ -112,7 +112,7 @@ public:
//- Destructor
virtual ~patchCloudSet();
virtual ~patchCloudSet() = default;
};

View File

@ -235,7 +235,7 @@ void Foam::patchSeedSet::calcSamples
subset.setSize(myMaxPoints);
// Subset patchFaces
patchFaces = UIndirectList<label>(patchFaces, subset)();
patchFaces = labelUIndList(patchFaces, subset)();
if (debug)
{
@ -364,10 +364,4 @@ Foam::patchSeedSet::patchSeedSet
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::patchSeedSet::~patchSeedSet()
{}
// ************************************************************************* //

View File

@ -103,7 +103,7 @@ public:
//- Destructor
virtual ~patchSeedSet();
virtual ~patchSeedSet() = default;
};

View File

@ -217,7 +217,7 @@ public:
autoPtr<sampledSet> clone() const
{
NotImplemented;
return autoPtr<sampledSet>(nullptr);
return autoPtr<sampledSet>();
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -152,12 +152,6 @@ Foam::sampledSets::sampledSets
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sampledSets::~sampledSets()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::sampledSets::verbose(const bool verbosity)

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,7 +43,7 @@ SourceFiles
#include "interpolation.H"
#include "coordSet.H"
#include "writer.H"
#include "wordReList.H"
#include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -175,7 +175,7 @@ class sampledSets
// Read from dictonary
//- Names of fields to sample
wordReList fieldSelection_;
wordRes fieldSelection_;
//- Interpolation scheme to use
word interpolationScheme_;
@ -273,7 +273,7 @@ public:
//- Destructor
virtual ~sampledSets();
virtual ~sampledSets() = default;
// Member Functions

View File

@ -209,12 +209,10 @@ public:
{
if (cell_)
{
return isoSurfCellPtr_();
}
else
{
return isoSurfPtr_();
return *isoSurfCellPtr_;
}
return *isoSurfPtr_;
}

View File

@ -157,7 +157,7 @@ public:
const isoSurface& surface() const
{
return surfPtr_();
return *surfPtr_;
}
//- Does the surface need an update?

View File

@ -41,7 +41,7 @@ Foam::sampledIsoSurfaceCell::sampleField
// Recreate geometry if time has changed
updateGeometry();
return tmp<Field<Type>>(new Field<Type>(vField, meshCells_));
return tmp<Field<Type>>::New(vField, meshCells_);
}

View File

@ -40,7 +40,7 @@ Foam::sampledIsoSurface::sampleField
// Recreate geometry if time has changed
updateGeometry();
return tmp<Field<Type>>(new Field<Type>(vField, surface().meshCells()));
return tmp<Field<Type>>::New(vField, surface().meshCells());
}

View File

@ -264,12 +264,6 @@ Foam::ensightSurfaceReader::ensightSurfaceReader(const fileName& fName)
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightSurfaceReader::~ensightSurfaceReader()
{}
// * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
@ -472,10 +466,10 @@ const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
}
}
surfPtr_.reset(new meshedSurface(xferMove(points), faces.xfer()));
surfPtr_.reset(new meshedSurface(std::move(points), std::move(faces)));
}
return surfPtr_();
return *surfPtr_;
}

View File

@ -146,7 +146,7 @@ public:
//- Destructor
virtual ~ensightSurfaceReader();
virtual ~ensightSurfaceReader() = default;
// Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -75,7 +75,7 @@ Foam::tmp<Foam::Field<Type>> Foam::ensightSurfaceReader::readField
std::ostringstream oss;
label nMask = 0;
for (size_t chari = 0; chari < fieldFileName.size(); chari++)
for (size_t chari = 0; chari < fieldFileName.size(); ++chari)
{
if (fieldFileName[chari] == '*')
{
@ -130,7 +130,7 @@ Foam::tmp<Foam::Field<Type>> Foam::ensightSurfaceReader::readField
label n = surfPtr_->size();
forAll(values, cmptI)
{
values.setSize(n);
values[cmptI].setCapacity(n);
}
// Read data file using schema generated while reading the surface

View File

@ -42,10 +42,4 @@ Foam::surfaceReader::surfaceReader(const fileName& fName)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceReader::~surfaceReader()
{}
// ************************************************************************* //

View File

@ -93,7 +93,7 @@ public:
//- Destructor
virtual ~surfaceReader();
virtual ~surfaceReader() = default;
// Member Functions

View File

@ -114,7 +114,7 @@ void Foam::sampledCuttingPlane::createGeometry()
false
),
mesh,
dimensionedScalar("zero", dimLength, 0)
dimensionedScalar(dimLength)
)
);
volScalarField& cellDistance = cellDistancePtr_();
@ -212,7 +212,7 @@ void Foam::sampledCuttingPlane::createGeometry()
false
),
pointMesh::New(mesh),
dimensionedScalar("zero", dimLength, 0)
dimensionedScalar(dimLength)
);
pDist.primitiveFieldRef() = pointDistance_;
@ -220,7 +220,6 @@ void Foam::sampledCuttingPlane::createGeometry()
pDist.write();
}
//- Direct from cell field and point field.
isoSurfPtr_.reset
(
@ -244,6 +243,43 @@ void Foam::sampledCuttingPlane::createGeometry()
//)
);
// Verify specified bounding box
if (!bounds_.empty())
{
// Bounding box does not overlap with (global) mesh!
if (!bounds_.overlaps(mesh.bounds()))
{
WarningInFunction
<< nl
<< name() << " : "
<< "Bounds " << bounds_
<< " do not overlap the mesh bounding box " << mesh.bounds()
<< nl << endl;
}
// Plane does not intersect the bounding box
if (!bounds_.intersects(plane_))
{
WarningInFunction
<< nl
<< name() << " : "
<< "Plane "<< plane_ << " does not intersect the bounds "
<< bounds_
<< nl << endl;
}
}
// Plane does not intersect the (global) mesh!
if (!mesh.bounds().intersects(plane_))
{
WarningInFunction
<< nl
<< name() << " : "
<< "Plane "<< plane_ << " does not intersect the mesh bounds "
<< mesh.bounds()
<< nl << endl;
}
if (debug)
{
print(Pout);
@ -297,12 +333,6 @@ Foam::sampledCuttingPlane::sampledCuttingPlane
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sampledCuttingPlane::~sampledCuttingPlane()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::sampledCuttingPlane::needsUpdate() const

View File

@ -133,7 +133,7 @@ public:
//- Destructor
virtual ~sampledCuttingPlane();
virtual ~sampledCuttingPlane() = default;
// Member Functions
@ -141,7 +141,7 @@ public:
//const isoSurfaceCell& surface() const
const isoSurface& surface() const
{
return isoSurfPtr_();
return *isoSurfPtr_;
}
//- Does the surface need an update?

View File

@ -37,7 +37,7 @@ Foam::sampledCuttingPlane::sampleField
const GeometricField<Type, fvPatchField, volMesh>& vField
) const
{
return tmp<Field<Type>>(new Field<Type>(vField, surface().meshCells()));
return tmp<Field<Type>>::New(vField, surface().meshCells());
}

View File

@ -47,7 +47,7 @@ Foam::sampledPatch::sampledPatch
(
const word& name,
const polyMesh& mesh,
const wordReList& patchNames,
const UList<wordRe>& patchNames,
const bool triangulate
)
:
@ -72,12 +72,6 @@ Foam::sampledPatch::sampledPatch
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sampledPatch::~sampledPatch()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::labelList& Foam::sampledPatch::patchIDs() const
@ -126,7 +120,8 @@ bool Foam::sampledPatch::update()
label sz = 0;
forAll(patchIDs(), i)
{
label patchi = patchIDs()[i];
const label patchi = patchIDs()[i];
const polyPatch& pp = mesh().boundaryMesh()[patchi];
if (isA<emptyPolyPatch>(pp))
@ -150,7 +145,7 @@ bool Foam::sampledPatch::update()
forAll(patchIDs(), i)
{
label patchi = patchIDs()[i];
const label patchi = patchIDs()[i];
patchStart_[i] = sz;
@ -204,11 +199,11 @@ void Foam::sampledPatch::remapFaces(const labelUList& faceMap)
MeshStorage::remapFaces(faceMap);
patchFaceLabels_ = labelList
(
UIndirectList<label>(patchFaceLabels_, faceMap)
labelUIndList(patchFaceLabels_, faceMap)
);
patchIndex_ = labelList
(
UIndirectList<label>(patchIndex_, faceMap)
labelUIndList(patchIndex_, faceMap)
);
// Redo patchStart.

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,6 +37,7 @@ SourceFiles
#include "sampledSurface.H"
#include "MeshedSurface.H"
#include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -59,7 +60,7 @@ class sampledPatch
// Private data
//- Name of patches
const wordReList patchNames_;
const wordRes patchNames_;
//- Corresponding patchIDs
mutable labelList patchIDs_;
@ -105,7 +106,7 @@ class sampledPatch
protected:
const wordReList& patchNames() const
const wordRes& patchNames() const
{
return patchNames_;
}
@ -136,7 +137,7 @@ public:
(
const word& name,
const polyMesh& mesh,
const wordReList& patchNames,
const UList<wordRe>& patchNames,
const bool triangulate = false
);
@ -150,7 +151,7 @@ public:
//- Destructor
virtual ~sampledPatch();
virtual ~sampledPatch() = default;
// Member Functions

View File

@ -52,12 +52,13 @@ Foam::sampledPlane::sampledPlane
sampledSurface(name, mesh),
cuttingPlane(planeDesc),
zoneKey_(zoneKey),
bounds_(),
triangulate_(triangulate),
needsUpdate_(true)
{
if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0)
if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) == -1)
{
Info<< "cellZone " << zoneKey_
Info<< "cellZone(s) " << zoneKey_
<< " not found - using entire mesh" << endl;
}
}
@ -72,7 +73,8 @@ Foam::sampledPlane::sampledPlane
:
sampledSurface(name, mesh, dict),
cuttingPlane(plane(dict)),
zoneKey_(keyType::null),
zoneKey_(dict.lookupOrDefault<keyType>("zone", keyType::null)),
bounds_(dict.lookupOrDefault("bounds", boundBox::invertedBox)),
triangulate_(dict.lookupOrDefault("triangulate", true)),
needsUpdate_(true)
{
@ -82,29 +84,21 @@ Foam::sampledPlane::sampledPlane
{
coordinateSystem cs(mesh, dict.subDict("coordinateSystem"));
point base = cs.globalPosition(planeDesc().refPoint());
vector norm = cs.globalVector(planeDesc().normal());
const point base = cs.globalPosition(planeDesc().refPoint());
const vector norm = cs.globalVector(planeDesc().normal());
// Assign the plane description
static_cast<plane&>(*this) = plane(base, norm);
}
dict.readIfPresent("zone", zoneKey_);
if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0)
if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) == -1)
{
Info<< "cellZone " << zoneKey_
Info<< "cellZone(s) " << zoneKey_
<< " not found - using entire mesh" << endl;
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sampledPlane::~sampledPlane()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::sampledPlane::needsUpdate() const
@ -137,9 +131,88 @@ bool Foam::sampledPlane::update()
sampledSurface::clearGeom();
const plane& pln = static_cast<const plane&>(*this);
// Verify specified bounding box
if (!bounds_.empty())
{
// Bounding box does not overlap with (global) mesh!
if (!bounds_.overlaps(mesh().bounds()))
{
WarningInFunction
<< nl
<< name() << " : "
<< "Bounds " << bounds_
<< " do not overlap the mesh bounding box " << mesh().bounds()
<< nl << endl;
}
// Plane does not intersect the bounding box
if (!bounds_.intersects(pln))
{
WarningInFunction
<< nl
<< name() << " : "
<< "Plane "<< pln << " does not intersect the bounds "
<< bounds_
<< nl << endl;
}
}
// Plane does not intersect the (global) mesh!
if (!mesh().bounds().intersects(pln))
{
WarningInFunction
<< nl
<< name() << " : "
<< "Plane "<< pln << " does not intersect the mesh bounds "
<< mesh().bounds()
<< nl << endl;
}
labelList selectedCells = mesh().cellZones().findMatching(zoneKey_).used();
if (returnReduce(selectedCells.empty(), andOp<bool>()))
bool fullMesh = returnReduce(selectedCells.empty(), andOp<bool>());
if (!bounds_.empty())
{
const auto& cellCentres = static_cast<const fvMesh&>(mesh()).C();
if (fullMesh)
{
const label len = mesh().nCells();
selectedCells.setSize(len);
label count = 0;
for (label celli=0; celli < len; ++celli)
{
if (bounds_.contains(cellCentres[celli]))
{
selectedCells[count++] = celli;
}
}
selectedCells.setSize(count);
}
else
{
label count = 0;
for (const label celli : selectedCells)
{
if (bounds_.contains(cellCentres[celli]))
{
selectedCells[count++] = celli;
}
}
selectedCells.setSize(count);
}
fullMesh = false;
}
if (fullMesh)
{
reCut(mesh(), triangulate_);
}

View File

@ -59,7 +59,10 @@ class sampledPlane
// Private data
//- If restricted to zones, name of this zone or a regular expression
keyType zoneKey_;
const keyType zoneKey_;
//- Optional bounding box to trim triangles against
const boundBox bounds_;
//- Triangulated faces or keep faces as is
const bool triangulate_;
@ -110,7 +113,7 @@ public:
//- Destructor
virtual ~sampledPlane();
virtual ~sampledPlane() = default;
// Member Functions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,7 +34,7 @@ Foam::sampledPlane::sampleField
const GeometricField<Type, fvPatchField, volMesh>& vField
) const
{
return tmp<Field<Type>>(new Field<Type>(vField, meshCells()));
return tmp<Field<Type>>::New(vField, meshCells());
}
@ -45,8 +45,10 @@ Foam::sampledPlane::interpolateField
const interpolation<Type>& interpolator
) const
{
// One value per point
tmp<Field<Type>> tvalues(new Field<Type>(points().size()));
// One value per point.
// Initialize with Zero to handle missed/degenerate faces
tmp<Field<Type>> tvalues(new Field<Type>(points().size(), Zero));
Field<Type>& values = tvalues.ref();
boolList pointDone(points().size(), false);
@ -54,19 +56,18 @@ Foam::sampledPlane::interpolateField
forAll(faces(), cutFacei)
{
const face& f = faces()[cutFacei];
const label celli = meshCells()[cutFacei];
forAll(f, faceVertI)
for (const label pointi : f)
{
label pointi = f[faceVertI];
if (!pointDone[pointi])
{
pointDone[pointi] = true;
values[pointi] = interpolator.interpolate
(
points()[pointi],
meshCells()[cutFacei]
celli
);
pointDone[pointi] = true;
}
}
}

View File

@ -137,7 +137,7 @@ Foam::tmp<Foam::scalarField> Foam::sampledSurface::sample
) const
{
NotImplemented;
return tmp<scalarField>(nullptr);
return tmp<scalarField>();
}
@ -147,7 +147,7 @@ Foam::tmp<Foam::vectorField> Foam::sampledSurface::sample
) const
{
NotImplemented;
return tmp<vectorField>(nullptr);
return tmp<vectorField>();
}
@ -157,7 +157,7 @@ Foam::tmp<Foam::sphericalTensorField> Foam::sampledSurface::sample
) const
{
NotImplemented;
return tmp<sphericalTensorField>(nullptr);
return tmp<sphericalTensorField>();
}
@ -167,7 +167,7 @@ Foam::tmp<Foam::symmTensorField> Foam::sampledSurface::sample
) const
{
NotImplemented;
return tmp<symmTensorField>(nullptr);
return tmp<symmTensorField>();
}
@ -177,7 +177,7 @@ Foam::tmp<Foam::tensorField> Foam::sampledSurface::sample
) const
{
NotImplemented;
return tmp<tensorField>(nullptr);
return tmp<tensorField>();
}

View File

@ -205,7 +205,7 @@ public:
autoPtr<sampledSurface> clone() const
{
NotImplemented;
return autoPtr<sampledSurface>(nullptr);
return autoPtr<sampledSurface>();
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -87,7 +87,7 @@ SourceFiles
#include "mergedSurf.H"
#include "volFieldsFwd.H"
#include "surfaceFieldsFwd.H"
#include "wordReList.H"
#include "wordRes.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -133,7 +133,7 @@ class sampledSurfaces
// Read from dictonary
//- Names of fields to sample
wordReList fieldSelection_;
wordRes fieldSelection_;
//- Interpolation scheme to use
word interpolationScheme_;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -158,7 +158,7 @@ Foam::sampledTriSurfaceMesh::nonCoupledboundaryTree() const
);
}
return boundaryTreePtr_();
return *boundaryTreePtr_;
}
@ -312,7 +312,7 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
patchi,
(
patches[patchi].name().empty()
? Foam::name("patch%d", patchi)
? word::printf("patch%d", patchi)
: patches[patchi].name()
)
);
@ -345,7 +345,7 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
zoneNames.set
(
regionid,
Foam::name("patch%d", regionid)
word::printf("patch%d", regionid)
);
}
@ -393,7 +393,7 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
}
if (name.empty())
{
name = ::Foam::name("patch%d", regionid);
name = word::printf("patch%d", regionid);
}
zoneLst[zoneI] = surfZone
@ -437,7 +437,7 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
}
// Subset cellOrFaceLabels (for compact faces)
cellOrFaceLabels = UIndirectList<label>(cellOrFaceLabels, faceMap)();
cellOrFaceLabels = labelUIndList(cellOrFaceLabels, faceMap)();
// Store any face per point (without using pointFaces())
labelList pointToFace(pointMap.size());
@ -647,7 +647,7 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
surfaceName,
mesh.time().constant(), // instance
"triSurface", // local
mesh, // registry
mesh.time(), // registry
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
@ -679,7 +679,7 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
dict.lookup("surface"),
mesh.time().constant(), // instance
"triSurface", // local
mesh, // registry
mesh.time(), // registry
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
@ -713,7 +713,7 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
name,
mesh.time().constant(), // instance
"triSurface", // local
mesh, // registry
mesh.time(), // registry
IOobject::NO_READ,
IOobject::NO_WRITE,
false
@ -787,6 +787,12 @@ bool Foam::sampledTriSurfaceMesh::update()
{
// Surface and mesh do not overlap at all. Guarantee a valid
// bounding box so we don't get any 'invalid bounding box' errors.
WarningInFunction
<< "Surface " << surface_.searchableSurface::name()
<< " does not overlap bounding box of mesh " << mesh().bounds()
<< endl;
bb = treeBoundBox(mesh().bounds());
const vector span(bb.span());

View File

@ -42,7 +42,7 @@ Foam::sampledThresholdCellFaces::sampleField
// Recreate geometry if time has changed
updateGeometry();
return tmp<Field<Type>>(new Field<Type>(vField, meshCells_));
return tmp<Field<Type>>::New(vField, meshCells_);
}

View File

@ -33,19 +33,6 @@ namespace Foam
makeSurfaceWriterType(boundaryDataSurfaceWriter);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::boundaryDataSurfaceWriter::boundaryDataSurfaceWriter()
:
surfaceWriter()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::boundaryDataSurfaceWriter::~boundaryDataSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -115,11 +115,11 @@ public:
// Constructors
//- Construct null
boundaryDataSurfaceWriter();
boundaryDataSurfaceWriter() = default;
//- Destructor
virtual ~boundaryDataSurfaceWriter();
virtual ~boundaryDataSurfaceWriter() = default;
// Member Functions

View File

@ -75,7 +75,7 @@ Foam::fileName Foam::boundaryDataSurfaceWriter::writeTemplate
IOobject::NO_WRITE,
false
),
0
label(0)
);
if (isNodeValues)

View File

@ -61,12 +61,6 @@ Foam::ensightSurfaceWriter::ensightSurfaceWriter(const dictionary& options)
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightSurfaceWriter::~ensightSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Note that ensight does supports geometry in a separate file,

View File

@ -117,7 +117,7 @@ public:
//- Destructor
virtual ~ensightSurfaceWriter();
virtual ~ensightSurfaceWriter() = default;
// Member Functions

View File

@ -70,7 +70,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeUncollated
}
// const scalar timeValue = Foam::name(this->mesh().time().timeValue());
const scalar timeValue = readScalar(IStringStream(timeDir)());
const scalar timeValue = readScalar(timeDir);
OFstream osCase(baseDir/surfName + ".case");
ensightGeoFile osGeom
@ -99,9 +99,13 @@ Foam::fileName Foam::ensightSurfaceWriter::writeUncollated
<< "model: 1 " << osGeom.name().name() << nl
<< nl
<< "VARIABLE" << nl
<< ensightPTraits<Type>::typeName << " per "
<< word(isNodeValues ? "node:" : "element:")
<< setw(3) << 1
<< ensightPTraits<Type>::typeName
<<
(
isNodeValues
? " per node: 1 " // time-set 1
: " per element: 1 " // time-set 1
)
<< setw(15) << varName
<< " " << surfName.c_str() << ".********." << varName << nl
<< nl
@ -175,7 +179,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
// surfName already validated
const fileName meshFile(baseDir/surfName + ".000000.mesh");
const scalar timeValue = readScalar(IStringStream(timeDir)());
const scalar timeValue = readScalar(timeDir);
label timeIndex = 0;
// Do case file
@ -190,7 +194,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
if (is.good() && dict.read(is))
{
dict.lookup("times") >> times;
const scalar timeValue = readScalar(IStringStream(timeDir)());
const scalar timeValue = readScalar(timeDir);
label index = findLower(times, timeValue);
timeIndex = index+1;
}
@ -280,9 +284,13 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
);
osCase
<< fieldType << " per "
<< word(isNodeValues ? "node:" : "element:")
<< setw(3) << 1
<< fieldType
<<
(
isNodeValues
? " per node: 1 " // time-set 1
: " per element: 1 " // time-set 1
)
<< setw(15) << varName
<< " data/******/" << varName
<< nl;

View File

@ -35,20 +35,6 @@ namespace Foam
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamSurfaceWriter::foamSurfaceWriter()
:
surfaceWriter()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamSurfaceWriter::~foamSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName Foam::foamSurfaceWriter::write

View File

@ -75,11 +75,11 @@ public:
// Constructors
//- Construct null
foamSurfaceWriter();
foamSurfaceWriter() = default;
//- Destructor
virtual ~foamSurfaceWriter();
virtual ~foamSurfaceWriter() = default;
// Member Functions

View File

@ -40,164 +40,84 @@ namespace Foam
defineSurfaceWriterWriteFields(nastranSurfaceWriter);
}
const Foam::Enum
<
Foam::nastranSurfaceWriter::writeFormat
Foam::nastranSurfaceWriter::loadFormat
>
Foam::nastranSurfaceWriter::writeFormatNames_
Foam::nastranSurfaceWriter::loadFormatNames_
{
{ writeFormat::wfShort, "short" },
{ writeFormat::wfLong, "long" },
{ writeFormat::wfFree, "free" },
};
const Foam::Enum
<
Foam::nastranSurfaceWriter::dataFormat
>
Foam::nastranSurfaceWriter::dataFormatNames_
{
{ dataFormat::dfPLOAD2, "PLOAD2" },
{ dataFormat::dfPLOAD4, "PLOAD4" },
{ loadFormat::PLOAD2, "PLOAD2" },
{ loadFormat::PLOAD4, "PLOAD4" },
};
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::nastranSurfaceWriter::formatOS(Ostream& os) const
{
os.setf(ios_base::scientific);
// Capitalise the E marker
os.setf(ios_base::uppercase);
label prec = 0;
label offset = 7;
switch (writeFormat_)
{
case wfShort:
{
prec = 8 - offset;
break;
}
case wfFree:
case wfLong:
{
prec = 16 - offset;
break;
}
default:
{
FatalErrorInFunction
<< "Unknown writeFormat enumeration" << abort(FatalError);
}
}
os.precision(prec);
}
Foam::Ostream& Foam::nastranSurfaceWriter::writeKeyword
(
Ostream& os,
const word& keyword
) const
{
os.setf(ios_base::left);
switch (writeFormat_)
{
case wfShort:
{
os << setw(8) << keyword;
break;
}
case wfLong:
{
os << setw(8) << word(keyword + '*');
break;
}
case wfFree:
{
os << keyword;
break;
}
}
os.unsetf(ios_base::left);
return os;
return fileFormats::NASCore::writeKeyword(os, keyword, writeFormat_);
}
void Foam::nastranSurfaceWriter::writeCoord
(
Ostream& os,
const point& p,
const point& pt,
const label pointI
) const
{
// Fixed short/long formats:
// 1 GRID
// 2 ID : point ID - requires starting index of 1
// 3 CP : co-ordinate system ID (blank)
// 4 X1 : point x cp-ordinate
// 5 X2 : point x cp-ordinate
// 6 X3 : point x cp-ordinate
// 7 CD : co-ordinate system for displacements (blank)
// 8 PS : single point constraints (blank)
// 3 CP : coordinate system ID (blank)
// 4 X1 : point x coordinate
// 5 X2 : point x coordinate
// 6 X3 : point x coordinate
// 7 CD : coordinate system for displacements (blank)
// 8 PS : single point constraints (blank)
// 9 SEID : super-element ID
writeKeyword(os, "GRID") << separator_;
os.setf(ios_base::right);
os.setf(std::ios_base::right);
writeValue(os, pointI+1) << separator_;
writeValue(os, "") << separator_;
writeValue(os, p.x()) << separator_;
writeValue(os, p.y()) << separator_;
writeValue(os, pt.x()) << separator_;
writeValue(os, pt.y()) << separator_;
switch (writeFormat_)
{
case wfShort:
case fieldFormat::SHORT :
{
os << setw(8) << p.z()
<< nl;
os.unsetf(ios_base::right);
os << setw(8) << pt.z() << nl;
os.unsetf(std::ios_base::right);
break;
}
case wfLong:
case fieldFormat::LONG :
{
os << nl;
os.unsetf(ios_base::right);
os.unsetf(std::ios_base::right);
writeKeyword(os, "");
os.setf(ios_base::right);
os.setf(std::ios_base::right);
writeValue(os, p.z()) << nl;
writeValue(os, pt.z()) << nl;
break;
}
case wfFree:
case fieldFormat::FREE :
{
writeValue(os, p.z()) << nl;
writeValue(os, pt.z()) << nl;
break;
}
default:
{
FatalErrorInFunction
<< "Unknown writeFormat enumeration" << abort(FatalError);
}
}
os.unsetf(ios_base::right);
os.unsetf(std::ios_base::right);
}
@ -226,23 +146,24 @@ void Foam::nastranSurfaceWriter::writeFace
writeKeyword(os, faceType) << separator_;
os.setf(ios_base::right);
os.setf(std::ios_base::right);
writeValue(os, nFace) << separator_;
writeValue(os, PID);
switch (writeFormat_)
{
case wfShort:
case fieldFormat::SHORT :
{
forAll(facePts, i)
for (const label pointi : facePts)
{
writeValue(os, facePts[i] + 1);
writeValue(os, pointi + 1);
}
break;
}
case wfLong:
case fieldFormat::LONG :
{
forAll(facePts, i)
{
@ -250,33 +171,29 @@ void Foam::nastranSurfaceWriter::writeFace
if (i == 1)
{
os << nl;
os.unsetf(ios_base::right);
os.unsetf(std::ios_base::right);
writeKeyword(os, "");
os.setf(ios_base::right);
os.setf(std::ios_base::right);
}
}
break;
}
case wfFree:
case fieldFormat::FREE :
{
forAll(facePts, i)
for (const label pointi : facePts)
{
os << separator_;
writeValue(os, facePts[i] + 1);
writeValue(os, pointi + 1);
}
break;
}
default:
{
FatalErrorInFunction
<< "Unknown writeFormat enumeration" << abort(FatalError);
}
}
os << nl;
os.unsetf(ios_base::right);
os.unsetf(std::ios_base::right);
}
@ -375,7 +292,7 @@ Foam::Ostream& Foam::nastranSurfaceWriter::writeFooter
// use single material ID
label MID = 1;
const label MID = 1;
writeKeyword(os, "MAT1") << separator_;
writeValue(os, MID);
@ -397,49 +314,48 @@ Foam::Ostream& Foam::nastranSurfaceWriter::writeFooter
Foam::nastranSurfaceWriter::nastranSurfaceWriter()
:
surfaceWriter(),
writeFormat_(wfShort),
writeFormat_(fieldFormat::SHORT),
fieldMap_(),
scale_(1.0)
scale_(1.0),
separator_()
{}
Foam::nastranSurfaceWriter::nastranSurfaceWriter(const dictionary& options)
:
surfaceWriter(),
writeFormat_(writeFormat::wfLong),
fieldMap_(),
scale_(options.lookupOrDefault("scale", 1.0)),
separator_("")
{
writeFormat_ = writeFormatNames_.lookupOrDefault
writeFormat_
(
"format",
options,
writeFormat::wfLong
);
if (writeFormat_ == wfFree)
fileFormats::NASCore::fieldFormatNames.lookupOrDefault
(
"format",
options,
fieldFormat::LONG
)
),
fieldMap_(),
scale_(options.lookupOrDefault<scalar>("scale", 1.0)),
separator_()
{
if (writeFormat_ == fieldFormat::FREE)
{
separator_ = ",";
}
List<Pair<word>> fieldSet(options.lookup("fields"));
List<Pair<word>> fieldPairs(options.lookup("fields"));
forAll(fieldSet, i)
for (const Pair<word>& item : fieldPairs)
{
dataFormat format = dataFormatNames_[fieldSet[i].second()];
fieldMap_.insert(fieldSet[i].first(), format);
// (field name => load format)
fieldMap_.insert
(
item.first(),
loadFormatNames_[item.second()]
);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::nastranSurfaceWriter::~nastranSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName Foam::nastranSurfaceWriter::write
@ -456,7 +372,7 @@ Foam::fileName Foam::nastranSurfaceWriter::write
}
OFstream os(outputDir/surfaceName + ".nas");
formatOS(os);
fileFormats::NASCore::setPrecision(os, writeFormat_);
if (verbose)
{
@ -472,7 +388,7 @@ Foam::fileName Foam::nastranSurfaceWriter::write
writeGeometry(os, surf, decomposedFaces);
writeFooter(os, surf)
<< "ENDDATA" << endl;
<< "ENDDATA" << nl;
return os.name();
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,16 +32,16 @@ Description
{
nastran
{
// From OpenFOAM field name to Nastran field name
// From OpenFOAM field name to NASTRAN field name
fields
(
(pMean PLOAD2)
(p PLOAD4)
(pMean PLOAD2)
(p PLOAD4)
);
// Optional scale
scale 2.0;
scale 2.0;
// Optional format
format free; //short, long, free
format free; // short, long, free
}
};
\endverbatim
@ -56,7 +56,7 @@ SourceFiles
#define nastranSurfaceWriter_H
#include "surfaceWriter.H"
#include "Enum.H"
#include "NASCore.H"
#include "OFstream.H"
#include "HashTable.H"
@ -75,17 +75,14 @@ class nastranSurfaceWriter
{
public:
enum writeFormat
{
wfShort,
wfLong,
wfFree
};
//- File field formats
using fieldFormat = Foam::fileFormats::NASCore::fieldFormat;
enum dataFormat
//- Output load format
enum loadFormat
{
dfPLOAD2,
dfPLOAD4
PLOAD2,
PLOAD4
};
@ -93,14 +90,13 @@ private:
// Private data
static const Enum<writeFormat> writeFormatNames_;
static const Enum<dataFormat> dataFormatNames_;
static const Enum<loadFormat> loadFormatNames_;
//- Write option
writeFormat writeFormat_;
//- Field format (width and separator)
fieldFormat writeFormat_;
//- Mapping from field name to data format enumeration
HashTable<dataFormat> fieldMap_;
HashTable<loadFormat> fieldMap_;
//- Scale to apply to values (default = 1.0)
scalar scale_;
@ -111,14 +107,11 @@ private:
// Private Member Functions
//- Initialise the output stream format parameters
void formatOS(Ostream& os) const;
//- Write a coordinate
void writeCoord
(
Ostream& os,
const point& p,
const point& pt,
const label pointI //!< 0-based Point Id
) const;
@ -159,7 +152,7 @@ private:
Ostream& writeFaceValue
(
Ostream& os,
const dataFormat& format,
const loadFormat format,
const Type& value,
const label EID //!< 1-based Element Id
) const;
@ -195,7 +188,7 @@ public:
//- Destructor
virtual ~nastranSurfaceWriter();
virtual ~nastranSurfaceWriter() = default;
// Member Functions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -38,17 +38,19 @@ Foam::Ostream& Foam::nastranSurfaceWriter::writeValue
{
switch (writeFormat_)
{
case wfShort:
case fieldFormat::SHORT :
{
os << setw(8) << value;
break;
}
case wfLong:
case fieldFormat::LONG :
{
os << setw(16) << value;
break;
}
case wfFree:
case fieldFormat::FREE :
{
os << value;
break;
@ -63,7 +65,7 @@ template<class Type>
Foam::Ostream& Foam::nastranSurfaceWriter::writeFaceValue
(
Ostream& os,
const dataFormat& format,
const loadFormat format,
const Type& value,
const label EID
) const
@ -87,16 +89,16 @@ Foam::Ostream& Foam::nastranSurfaceWriter::writeFaceValue
Type scaledValue = scale_*value;
// Write keyword
writeKeyword(os, dataFormatNames_[format]) << separator_;
writeKeyword(os, loadFormatNames_[format]) << separator_;
// Write load set ID
os.setf(ios_base::right);
os.setf(std::ios_base::right);
writeValue(os, SID) << separator_;
switch (format)
{
case dfPLOAD2:
case loadFormat::PLOAD2 :
{
if (pTraits<Type>::nComponents == 1)
{
@ -105,7 +107,7 @@ Foam::Ostream& Foam::nastranSurfaceWriter::writeFaceValue
else
{
WarningInFunction
<< dataFormatNames_[format] << " requires scalar values "
<< loadFormatNames_[format] << " requires scalar values "
<< "and cannot be used for higher rank values"
<< endl;
@ -116,27 +118,20 @@ Foam::Ostream& Foam::nastranSurfaceWriter::writeFaceValue
break;
}
case dfPLOAD4:
case loadFormat::PLOAD4 :
{
writeValue(os, EID);
for (direction dirI = 0; dirI < pTraits<Type>::nComponents; ++dirI)
for (direction d = 0; d < pTraits<Type>::nComponents; ++d)
{
os << separator_;
writeValue(os, component(scaledValue, dirI));
writeValue(os, component(scaledValue, d));
}
break;
}
default:
{
FatalErrorInFunction
<< "Unhandled enumeration " << dataFormatNames_[format]
<< exit(FatalError);
}
}
os.unsetf(ios_base::right);
os.unsetf(std::ios_base::right);
os << nl;
@ -167,7 +162,7 @@ Foam::fileName Foam::nastranSurfaceWriter::writeTemplate
return fileName::null;
}
const dataFormat& format(fieldMap_[fieldName]);
const loadFormat& format(fieldMap_[fieldName]);
if (!isDir(outputDir/fieldName))
{
@ -178,7 +173,7 @@ Foam::fileName Foam::nastranSurfaceWriter::writeTemplate
const scalar timeValue = 0.0;
OFstream os(outputDir/fieldName/surfaceName + ".nas");
formatOS(os);
fileFormats::NASCore::setPrecision(os, writeFormat_);
if (verbose)
{
@ -199,21 +194,19 @@ Foam::fileName Foam::nastranSurfaceWriter::writeTemplate
<< "$ Field data" << nl
<< "$" << nl;
label elemId = 0;
if (isNodeValues)
{
label elemId = 0;
forAll(decomposedFaces, i)
for (const DynamicList<face>& dFaces : decomposedFaces)
{
const DynamicList<face>& dFaces = decomposedFaces[i];
forAll(dFaces, facei)
for (const face& f : dFaces)
{
Type v = Zero;
const face& f = dFaces[facei];
forAll(f, fptI)
for (const label verti : f)
{
v += values[f[fptI]];
v += values[verti];
}
v /= f.size();
@ -223,11 +216,8 @@ Foam::fileName Foam::nastranSurfaceWriter::writeTemplate
}
else
{
label elemId = 0;
forAll(decomposedFaces, i)
for (const DynamicList<face>& dFaces : decomposedFaces)
{
const DynamicList<face>& dFaces = decomposedFaces[i];
forAll(dFaces, facei)
{
writeFaceValue(os, format, values[facei], ++elemId);

View File

@ -48,12 +48,6 @@ Foam::proxySurfaceWriter::proxySurfaceWriter(const word& ext)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::proxySurfaceWriter::~proxySurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName Foam::proxySurfaceWriter::write

View File

@ -70,7 +70,7 @@ public:
//- Destructor
virtual ~proxySurfaceWriter();
virtual ~proxySurfaceWriter() = default;
// Member Functions

View File

@ -222,12 +222,6 @@ Foam::rawSurfaceWriter::rawSurfaceWriter(const dictionary& options)
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::rawSurfaceWriter::~rawSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName Foam::rawSurfaceWriter::write

View File

@ -110,7 +110,7 @@ public:
//- Destructor
virtual ~rawSurfaceWriter();
virtual ~rawSurfaceWriter() = default;
// Member Functions

View File

@ -74,20 +74,6 @@ namespace Foam
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::starcdSurfaceWriter::starcdSurfaceWriter()
:
surfaceWriter()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::starcdSurfaceWriter::~starcdSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName Foam::starcdSurfaceWriter::write

View File

@ -98,11 +98,11 @@ public:
// Constructors
//- Construct null
starcdSurfaceWriter();
starcdSurfaceWriter() = default;
//- Destructor
virtual ~starcdSurfaceWriter();
virtual ~starcdSurfaceWriter() = default;
// Member Functions

View File

@ -97,16 +97,4 @@ Foam::surfaceWriter::New(const word& writeType, const dictionary& optDict)
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceWriter::surfaceWriter()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceWriter::~surfaceWriter()
{}
// ************************************************************************* //

View File

@ -97,11 +97,11 @@ public:
// Constructors
//- Construct null
surfaceWriter();
surfaceWriter() = default;
//- Destructor
virtual ~surfaceWriter();
virtual ~surfaceWriter() = default;
// Member Functions

View File

@ -55,9 +55,8 @@ void Foam::vtkSurfaceWriter::writeGeometry
// Write vertex coords
os << "POINTS " << points.size() << " double" << nl;
forAll(points, pointi)
for (const point& pt : points)
{
const point& pt = points[pointi];
os << float(pt.x()) << ' '
<< float(pt.y()) << ' '
<< float(pt.z()) << nl;
@ -67,22 +66,20 @@ void Foam::vtkSurfaceWriter::writeGeometry
// Write faces
label nNodes = 0;
forAll(faces, facei)
for (const face& f : faces)
{
nNodes += faces[facei].size();
nNodes += f.size();
}
os << "POLYGONS " << faces.size() << ' '
<< faces.size() + nNodes << nl;
forAll(faces, facei)
for (const face& f : faces)
{
const face& f = faces[facei];
os << f.size();
forAll(f, fp)
for (const label verti : f)
{
os << ' ' << f[fp];
os << ' ' << verti;
}
os << nl;
}
@ -130,9 +127,8 @@ namespace Foam
{
os << "3 " << values.size() << " float" << nl;
forAll(values, elemI)
for (const vector& v : values)
{
const vector& v = values[elemI];
os << float(v[0]) << ' '
<< float(v[1]) << ' '
<< float(v[2]) << nl;
@ -149,9 +145,8 @@ namespace Foam
{
os << "1 " << values.size() << " float" << nl;
forAll(values, elemI)
for (const sphericalTensor& v : values)
{
const sphericalTensor& v = values[elemI];
os << float(v[0]) << nl;
}
}
@ -166,9 +161,8 @@ namespace Foam
{
os << "6 " << values.size() << " float" << nl;
forAll(values, elemI)
for (const symmTensor& v : values)
{
const symmTensor& v = values[elemI];
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2])
<< ' '
<< float(v[3]) << ' ' << float(v[4]) << ' ' << float(v[5])
@ -187,9 +181,8 @@ namespace Foam
{
os << "9 " << values.size() << " float" << nl;
forAll(values, elemI)
for (const tensor& v : values)
{
const tensor& v = values[elemI];
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2])
<< ' '
<< float(v[3]) << ' ' << float(v[4]) << ' ' << float(v[5])
@ -211,12 +204,12 @@ Foam::vtkSurfaceWriter::vtkSurfaceWriter()
{}
Foam::vtkSurfaceWriter::vtkSurfaceWriter(const dictionary& dict)
Foam::vtkSurfaceWriter::vtkSurfaceWriter(const dictionary& options)
:
surfaceWriter(),
writePrecision_
(
dict.lookupOrDefault
options.lookupOrDefault
(
"writePrecision",
IOstream::defaultPrecision()
@ -225,12 +218,6 @@ Foam::vtkSurfaceWriter::vtkSurfaceWriter(const dictionary& dict)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::vtkSurfaceWriter::~vtkSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName Foam::vtkSurfaceWriter::write
@ -260,7 +247,7 @@ Foam::fileName Foam::vtkSurfaceWriter::write
}
// create write methods
// Create write methods
defineSurfaceWriterWriteFields(Foam::vtkSurfaceWriter);

View File

@ -93,7 +93,7 @@ public:
//- Destructor
virtual ~vtkSurfaceWriter();
virtual ~vtkSurfaceWriter() = default;
// Member Functions

View File

@ -73,7 +73,7 @@ Foam::surfMeshPlaneSampler::surfMeshPlaneSampler
triangulate_(triangulate),
needsUpdate_(true)
{
if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0)
if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) == -1)
{
Info<< "cellZone " << zoneKey_
<< " not found - using entire mesh" << endl;
@ -109,7 +109,7 @@ Foam::surfMeshPlaneSampler::surfMeshPlaneSampler
dict.readIfPresent("zone", zoneKey_);
if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0)
if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) == -1)
{
Info<< "cellZone " << zoneKey_
<< " not found - using entire mesh" << endl;

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-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -53,8 +53,7 @@ Foam::surfMeshSampler::getOrCreateSurfMesh() const
IOobject::NO_READ,
IOobject::NO_WRITE
),
xferCopy(pointField()), // initially no points
xferCopy(faceList()), // initially no faces
meshedSurface(), // Create as empty surface
name()
);
ptr->setWriteOption(IOobject::NO_WRITE);
@ -121,12 +120,6 @@ Foam::surfMeshSampler::surfMeshSampler
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfMeshSampler::~surfMeshSampler()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfMeshSampler::create() const
@ -177,13 +170,13 @@ const Foam::surfMesh& Foam::surfMeshSampler::surface() const
Foam::label Foam::surfMeshSampler::sample
(
const UList<word>& fields
const UList<word>& fieldNames
) const
{
label count = 0;
forAll(fields, fieldi)
for (const word& fieldName : fieldNames)
{
if (sample(fields[fieldi]))
if (sample(fieldName))
{
++count;
}
@ -193,7 +186,7 @@ Foam::label Foam::surfMeshSampler::sample
}
Foam::label Foam::surfMeshSampler::write(const wordReList& select) const
Foam::label Foam::surfMeshSampler::write(const wordRes& select) const
{
label count =
(

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-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -111,7 +111,7 @@ protected:
//- Write the given fields
template<class Type>
label writeFields(const wordReList& select) const;
label writeFields(const wordRes& select) const;
public:
@ -181,7 +181,7 @@ public:
autoPtr<surfMeshSampler> clone() const
{
NotImplemented;
return autoPtr<surfMeshSampler>(nullptr);
return autoPtr<surfMeshSampler>();
}
@ -198,7 +198,7 @@ public:
//- Destructor
virtual ~surfMeshSampler();
virtual ~surfMeshSampler() = default;
// Member Functions
@ -253,16 +253,16 @@ public:
virtual bool sample(const word& fieldName) const = 0;
//- Sample from volume fields to specified surface fields.
virtual label sample(const UList<word>& fields) const;
virtual label sample(const UList<word>& fieldNames) const;
// Write
//- Write specified fields
virtual label write(const wordReList& fieldSelection) const;
virtual label write(const wordRes& fieldSelection) const;
//- Write
virtual void print(Ostream&) const;
virtual void print(Ostream& os) const;
};

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-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -106,19 +106,19 @@ Foam::surfMeshSampler::getOrCreateSurfField
template<class Type>
Foam::label Foam::surfMeshSampler::writeFields
(
const wordReList& select
const wordRes& select
) const
{
typedef DimensionedField<Type, surfGeoMesh> SurfFieldType;
const surfMesh& s = surface();
wordList names = s.sortedNames<SurfFieldType>(select);
forAll(names, namei)
const wordList fieldNames = s.sortedNames<SurfFieldType>(select);
for (const word& fieldName : fieldNames)
{
s.lookupObject<SurfFieldType>(names[namei]).write();
s.lookupObject<SurfFieldType>(fieldName).write();
}
return names.size();
return fieldNames.size();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,7 +31,6 @@ License
#include "volPointInterpolation.H"
#include "PatchTools.H"
#include "mapPolyMesh.H"
#include "wordRes.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -132,12 +131,6 @@ Foam::surfMeshSamplers::surfMeshSamplers
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfMeshSamplers::~surfMeshSamplers()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfMeshSamplers::verbose(const bool verbosity)
@ -279,10 +272,10 @@ bool Foam::surfMeshSamplers::write()
// or elsewhere
// This could be more efficient
wordReList select(fieldSelection_.size() + derivedNames_.size());
wordRes select(fieldSelection_.size() + derivedNames_.size());
label nElem = 0;
for (const auto& item : fieldSelection_)
for (const wordRe& item : fieldSelection_)
{
select[nElem++] = item;
}
@ -291,8 +284,8 @@ bool Foam::surfMeshSamplers::write()
select[nElem++] = derivedName;
}
// avoid duplicate entries
select = wordRes::uniq(select);
// Avoid duplicate entries
select.uniq();
for (const surfMeshSampler& s : surfaces())
{
@ -308,15 +301,13 @@ bool Foam::surfMeshSamplers::read(const dictionary& dict)
fieldSelection_.clear();
derivedNames_.clear();
const bool createOnRead =
dict.lookupOrDefault<Switch>("createOnRead", false);
const bool createOnRead = dict.lookupOrDefault("createOnRead", false);
if (dict.found("surfaces"))
{
fieldSelection_ = wordRes::uniq
(
wordReList(dict.lookup("fields"))
);
dict.lookup("fields") >> fieldSelection_;
fieldSelection_.uniq();
Info<< type() << " fields: " << fieldSelection_ << nl;
if (dict.readIfPresent("derived", derivedNames_))

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -82,7 +82,7 @@ SourceFiles
#include "surfMeshSampler.H"
#include "volFieldsFwd.H"
#include "surfaceFieldsFwd.H"
#include "wordReList.H"
#include "wordRes.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -119,7 +119,7 @@ class surfMeshSamplers
// Read from dictonary
//- Names of fields to sample
wordReList fieldSelection_;
wordRes fieldSelection_;
//- Names of derived fields to create and sample
wordList derivedNames_;
@ -183,7 +183,7 @@ public:
//- Destructor
virtual ~surfMeshSamplers();
virtual ~surfMeshSamplers() = default;
// Member Functions

View File

@ -33,8 +33,8 @@ License
// Set values for what is close to zero and what is considered to
// be positive (and not just rounding noise)
//! \cond localScope
const Foam::scalar zeroish = Foam::SMALL;
const Foam::scalar positive = Foam::SMALL * 1E3;
static const Foam::scalar zeroish = Foam::SMALL;
static const Foam::scalar positive = Foam::SMALL * 1E3;
//! \endcond
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -49,31 +49,25 @@ void Foam::cuttingPlane::calcCutCells
const labelListList& cellEdges = mesh.cellEdges();
const edgeList& edges = mesh.edges();
label listSize = cellEdges.size();
if (notNull(cellIdLabels))
{
listSize = cellIdLabels.size();
}
const label len =
(notNull(cellIdLabels) ? cellIdLabels.size() : cellEdges.size());
meshCells_.setSize(listSize);
meshCells_.setSize(len);
label cutcelli(0);
// Find the cut cells by detecting any cell that uses points with
// opposing dotProducts.
for (label listI = 0; listI < listSize; ++listI)
for (label listi = 0; listi < len; ++listi)
{
label celli = listI;
if (notNull(cellIdLabels))
{
celli = cellIdLabels[listI];
}
const label celli =
(notNull(cellIdLabels) ? cellIdLabels[listi] : listi);
const labelList& cEdges = cellEdges[celli];
label nCutEdges = 0;
forAll(cEdges, i)
for (const label edgei : cEdges)
{
const edge& e = edges[cEdges[i]];
const edge& e = edges[edgei];
if
(
@ -81,9 +75,7 @@ void Foam::cuttingPlane::calcCutCells
|| (dotProducts[e[1]] < zeroish && dotProducts[e[0]] > positive)
)
{
nCutEdges++;
if (nCutEdges > 2)
if (++nCutEdges > 2)
{
meshCells_[cutcelli++] = celli;
break;
@ -129,7 +121,7 @@ void Foam::cuttingPlane::intersectEdges
const point& p0 = points[e[0]];
const point& p1 = points[e[1]];
scalar alpha = lineIntersect(linePointRef(p0, p1));
const scalar alpha = lineIntersect(linePointRef(p0, p1));
if (alpha < zeroish)
{
@ -186,10 +178,8 @@ bool Foam::cuttingPlane::walkCell
// If so should e.g. decompose the cells on both faces and redo
// the calculation.
forAll(fEdges, i)
for (const label edge2I : fEdges)
{
label edge2I = fEdges[i];
if (edge2I != edgeI && edgePoint[edge2I] != -1)
{
nextEdgeI = edge2I;
@ -212,7 +202,7 @@ bool Foam::cuttingPlane::walkCell
edgeI = nextEdgeI;
nIter++;
++nIter;
if (nIter > 1000)
{
@ -232,16 +222,14 @@ bool Foam::cuttingPlane::walkCell
{
return true;
}
else
{
WarningInFunction
<< "Did not find closed walk along surface of cell " << celli
<< " starting from edge " << startEdgeI << nl
<< "Collected cutPoints so far:" << faceVerts
<< endl;
return false;
}
WarningInFunction
<< "Did not find closed walk along surface of cell " << celli
<< " starting from edge " << startEdgeI << nl
<< "Collected cutPoints so far:" << faceVerts
<< endl;
return false;
}
@ -261,19 +249,15 @@ void Foam::cuttingPlane::walkCellCuts
// scratch space for calculating the face vertices
DynamicList<label> faceVerts(10);
forAll(meshCells_, i)
for (const label celli : meshCells_)
{
label celli = meshCells_[i];
// Find the starting edge to walk from.
const labelList& cEdges = mesh.cellEdges()[celli];
label startEdgeI = -1;
forAll(cEdges, cEdgeI)
for (const label edgeI : cEdges)
{
label edgeI = cEdges[cEdgeI];
if (edgePoint[edgeI] != -1)
{
startEdgeI = edgeI;
@ -309,7 +293,7 @@ void Foam::cuttingPlane::walkCellCuts
f.flip();
}
// the cut faces are usually quite ugly, so optionally triangulate
// The cut faces can be quite ugly, so optionally triangulate
if (triangulate)
{
label nTri = f.triangles(cutPoints, dynCutFaces);
@ -326,8 +310,18 @@ void Foam::cuttingPlane::walkCellCuts
}
}
this->storedFaces().transfer(dynCutFaces);
meshCells_.transfer(dynCutCells);
// No cuts? Then no need for any of this information
if (dynCutCells.empty())
{
this->storedPoints().clear();
this->storedFaces().clear();
meshCells_.clear();
}
else
{
this->storedFaces().transfer(dynCutFaces);
meshCells_.transfer(dynCutCells);
}
}
@ -353,7 +347,6 @@ Foam::cuttingPlane::cuttingPlane
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cuttingPlane::reCut
@ -391,6 +384,7 @@ void Foam::cuttingPlane::remapFaces
{
MeshStorage::remapFaces(faceMap);
// Renumber
List<label> newCutCells(faceMap.size());
forAll(faceMap, facei)
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -116,7 +116,7 @@ protected:
// Constructors
//- Construct plane description without cutting
cuttingPlane(const plane&);
cuttingPlane(const plane& pln);
// Protected Member Functions
@ -141,8 +141,8 @@ public:
// possibly restricted to a list of cells
cuttingPlane
(
const plane&,
const primitiveMesh&,
const plane& pln,
const primitiveMesh& mesh,
const bool triangulate,
const labelUList& cellIdLabels = labelUList::null()
);
@ -178,7 +178,8 @@ public:
// Member Operators
void operator=(const cuttingPlane&);
//- Copy assignment
void operator=(const cuttingPlane& rhs);
};

View File

@ -36,7 +36,7 @@ Foam::tmp<Foam::Field<Type>> Foam::cuttingPlane::sample
const Field<Type>& fld
) const
{
return tmp<Field<Type>>(new Field<Type>(fld, meshCells()));
return tmp<Field<Type>>::New(fld, meshCells());
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -748,7 +748,7 @@ void Foam::isoSurface::calcSnappedPoint
FixedList<scalar, 4> s;
FixedList<point, 4> pt;
label fp = findIndex(f, pointi);
label fp = f.find(pointi);
s[0] = isoFraction(pVals[pointi], cVals[own]);
pt[0] = (1.0-s[0])*pts[pointi] + s[0]*cc[own];
@ -1266,13 +1266,7 @@ Foam::triSurface Foam::isoSurface::subsetMesh
{
const boolList include
(
createWithValues<boolList>
(
s.size(),
false,
newToOldFaces,
true
)
ListOps::createWithValue<bool>(s.size(), newToOldFaces, true, false)
);
newToOldPoints.setSize(s.points().size());
@ -1695,19 +1689,21 @@ Foam::isoSurface::isoSurface
}
// Transfer to mesh storage
// Transfer to mesh storage. Note, an iso-surface has no zones
{
// Recover the pointField
pointField pts;
tmpsurf.swapPoints(pts);
// Transcribe from triFace to face
faceList faces;
tmpsurf.triFaceFaces(faces);
// An iso-surface has no zones
surfZoneList zones(0);
tmpsurf.clearOut();
// Reset primitive data (points, faces and zones)
this->MeshStorage::reset
(
tmpsurf.xferPoints(), faces.xfer(), zones.xfer()
);
MeshStorage updated(std::move(pts), std::move(faces), surfZoneList());
this->MeshStorage::transfer(updated);
}
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -226,12 +226,12 @@ Foam::labelPair Foam::isoSurfaceCell::findCommonPoints
labelPair common(-1, -1);
label fp0 = 0;
label fp1 = findIndex(tri1, tri0[fp0]);
label fp1 = tri1.find(tri0[fp0]);
if (fp1 == -1)
{
fp0 = 1;
fp1 = findIndex(tri1, tri0[fp0]);
fp1 = tri1.find(tri0[fp0]);
}
if (fp1 != -1)
@ -553,7 +553,7 @@ void Foam::isoSurfaceCell::genPointTris
label nextFp = f.fcIndex(fp);
triFace tri(f[fp0], f[fp], f[nextFp]);
label index = findIndex(tri, pointi);
label index = tri.find(pointi);
if (index == -1)
{
@ -616,8 +616,6 @@ void Foam::isoSurfaceCell::genPointTris
const pointField& pts = mesh_.points();
const cell& cFaces = mesh_.cells()[celli];
FixedList<label, 4> tet;
// Make tet from this face to the 4th point (same as cellcentre in
// non-tet cells)
const face& f = mesh_.faces()[facei];
@ -631,7 +629,7 @@ void Foam::isoSurfaceCell::genPointTris
{
label p1 = f1[fp];
if (findIndex(f, p1) == -1)
if (!f.found(p1))
{
ccPointi = p1;
break;
@ -645,7 +643,7 @@ void Foam::isoSurfaceCell::genPointTris
// Tet between index..index-1, index..index+1, index..cc
label index = findIndex(f, pointi);
label index = f.find(pointi);
label b = f[f.fcIndex(index)];
label c = f[f.rcIndex(index)];
@ -1236,13 +1234,7 @@ Foam::triSurface Foam::isoSurfaceCell::subsetMesh
{
const boolList include
(
createWithValues<boolList>
(
s.size(),
false,
newToOldFaces,
true
)
ListOps::createWithValue<bool>(s.size(), newToOldFaces, true, false)
);
newToOldPoints.setSize(s.points().size());
@ -1569,19 +1561,21 @@ Foam::isoSurfaceCell::isoSurfaceCell
}
// Transfer to mesh storage
// Transfer to mesh storage. Note, an iso-surface has no zones
{
// Recover the pointField
pointField pts;
tmpsurf.swapPoints(pts);
// Transcribe from triFace to face
faceList faces;
tmpsurf.triFaceFaces(faces);
// An iso-surface has no zones
surfZoneList zones(0);
tmpsurf.clearOut();
// Reset primitive data (points, faces and zones)
this->MeshStorage::reset
(
tmpsurf.xferPoints(), faces.xfer(), zones.xfer()
);
MeshStorage updated(std::move(pts), std::move(faces), surfZoneList());
this->MeshStorage::transfer(updated);
}
}

View File

@ -360,7 +360,7 @@ void Foam::isoSurfaceCell::generateTriPoints
{
oppositeI = f1[fp];
if (findIndex(f0, oppositeI) == -1)
if (!f0.found(oppositeI))
{
break;
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -152,7 +152,7 @@ Foam::discreteSurface::nonCoupledboundaryTree() const
);
}
return boundaryTreePtr_();
return *boundaryTreePtr_;
}
@ -306,7 +306,7 @@ bool Foam::discreteSurface::update(const meshSearch& meshSearcher)
patchi,
(
patches[patchi].name().empty()
? Foam::name("patch%d", patchi)
? word::printf("patch%d", patchi)
: patches[patchi].name()
)
);
@ -339,7 +339,7 @@ bool Foam::discreteSurface::update(const meshSearch& meshSearcher)
zoneNames.set
(
regionid,
Foam::name("patch%d", regionid)
word::printf("patch%d", regionid)
);
}
@ -387,7 +387,7 @@ bool Foam::discreteSurface::update(const meshSearch& meshSearcher)
}
if (name.empty())
{
name = ::Foam::name("patch%d", regionid);
name = word::printf("patch%d", regionid);
}
zoneLst[zoneI] = surfZone
@ -431,7 +431,7 @@ bool Foam::discreteSurface::update(const meshSearch& meshSearcher)
}
// Subset cellOrFaceLabels (for compact faces)
cellOrFaceLabels = UIndirectList<label>(cellOrFaceLabels, faceMap)();
cellOrFaceLabels = labelUIndList(cellOrFaceLabels, faceMap)();
// Store any face per point (without using pointFaces())
labelList pointToFace(pointMap.size());
@ -642,7 +642,7 @@ Foam::discreteSurface::discreteSurface
surfaceName,
mesh.time().constant(), // instance
"triSurface", // local
mesh, // registry
mesh.time(), // registry
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
@ -680,7 +680,7 @@ Foam::discreteSurface::discreteSurface
dict.lookup("surface"),
mesh.time().constant(), // instance
"triSurface", // local
mesh, // registry
mesh.time(), // registry
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
@ -716,7 +716,7 @@ Foam::discreteSurface::discreteSurface
name,
mesh.time().constant(), // instance
"triSurface", // local
mesh, // registry
mesh.time(), // registry
IOobject::NO_READ,
IOobject::NO_WRITE,
false