ENH: adjust sampling onto meshed surfaces (#1600)

- base level surface container is now a meshedSurface instead of
  a triSurface. This avoid automatic triangulation of surfaces
  when they are read, and simplifies the internals.

- sampling types:
  * "meshedSurface" (compat: "sampledTriSurfaceMesh")
  * "meshedSurfaceNormal" (compat: "sampledTriSurfaceMeshNormal")
This commit is contained in:
Mark Olesen
2020-03-12 15:57:57 +01:00
parent e3d4443871
commit 06c4dc34ee
11 changed files with 240 additions and 353 deletions

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Version: v1912 \\ / O peration | Version: v2006
\\ / A nd | Website: www.openfoam.com \\ / A nd | Website: www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -14,7 +14,7 @@ region1
sampledSurfaceDict sampledSurfaceDict
{ {
type sampledTriSurfaceMesh; type meshedSurface;
regionType cells; regionType cells;
interpolate true; interpolate true;
surface $triSurface1; surface $triSurface1;

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Version: v1912 \\ / O peration | Version: v2006
\\ / A nd | Website: www.openfoam.com \\ / A nd | Website: www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -12,7 +12,7 @@ regionType sampledSurface;
sampledSurfaceDict sampledSurfaceDict
{ {
type sampledTriSurfaceMesh; type meshedSurface;
surface $triSurface; surface $triSurface;
source cells; source cells;
interpolate true; interpolate true;

View File

@ -44,11 +44,11 @@ sampledSurface/isoSurface/sampledIsoSurfaceTopo.C
sampledSurface/distanceSurface/sampledDistanceSurface.C sampledSurface/distanceSurface/sampledDistanceSurface.C
sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C
sampledSurface/sampledCuttingSurface/sampledCuttingSurface.C sampledSurface/sampledCuttingSurface/sampledCuttingSurface.C
sampledSurface/sampledMeshedSurface/sampledMeshedSurface.C
sampledSurface/sampledMeshedSurface/sampledMeshedSurfaceNormal.C
sampledSurface/sampledSurface/sampledSurface.C sampledSurface/sampledSurface/sampledSurface.C
sampledSurface/sampledSurface/sampledSurfaceRegister.C sampledSurface/sampledSurface/sampledSurfaceRegister.C
sampledSurface/sampledSurfaces/sampledSurfaces.C sampledSurface/sampledSurfaces/sampledSurfaces.C
sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C
sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMeshNormal.C
sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C
readers = sampledSurface/readers readers = sampledSurface/readers

View File

@ -26,7 +26,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "sampledTriSurfaceMesh.H" #include "sampledMeshedSurface.H"
#include "meshSearch.H" #include "meshSearch.H"
#include "Tuple2.H" #include "Tuple2.H"
#include "globalIndex.H" #include "globalIndex.H"
@ -39,9 +39,9 @@ License
const Foam::Enum const Foam::Enum
< <
Foam::sampledTriSurfaceMesh::samplingSource Foam::sampledMeshedSurface::samplingSource
> >
Foam::sampledTriSurfaceMesh::samplingSourceNames_ Foam::sampledMeshedSurface::samplingSourceNames_
({ ({
{ samplingSource::cells, "cells" }, { samplingSource::cells, "cells" },
{ samplingSource::insideCells, "insideCells" }, { samplingSource::insideCells, "insideCells" },
@ -51,12 +51,22 @@ Foam::sampledTriSurfaceMesh::samplingSourceNames_
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(sampledTriSurfaceMesh, 0); defineTypeNameAndDebug(sampledMeshedSurface, 0);
addToRunTimeSelectionTable // Use shorter name only
addNamedToRunTimeSelectionTable
( (
sampledSurface, sampledSurface,
sampledTriSurfaceMesh, sampledMeshedSurface,
word word,
meshedSurface
);
// Compatibility name (1912)
addNamedToRunTimeSelectionTable
(
sampledSurface,
sampledMeshedSurface,
word,
sampledTriSurfaceMesh
); );
//- Private class for finding nearest //- Private class for finding nearest
@ -104,50 +114,63 @@ inline static IOobject selectReadIO(const word& name, const Time& runTime)
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::sampledTriSurfaceMesh::setZoneMap void Foam::sampledMeshedSurface::setZoneMap()
(
const surfZoneList& zoneLst,
labelList& zoneIds
)
{ {
label sz = 0; // Ensure zoneIds_ are correctly populated
for (const surfZone& zn : zoneLst)
{
sz += zn.size();
}
zoneIds.resize(sz);
forAll(zoneLst, zonei) const meshedSurface& s = static_cast<const meshedSurface&>(*this);
const auto& zones = s.surfZones();
zoneIds_.resize(s.size());
// Trivial case
if (zoneIds_.empty() || zones.size() <= 1)
{ {
const surfZone& zn = zoneLst[zonei]; zoneIds_ = 0;
return;
}
label beg = 0;
forAll(zones, zonei)
{
const label len = min(zones[zonei].size(), zoneIds_.size() - beg);
// Assign sub-zone Ids // Assign sub-zone Ids
SubList<label>(zoneIds, zn.range()) = zonei; SubList<label>(zoneIds_, len, beg) = zonei;
beg += len;
}
// Anything remaining? Should not happen
{
const label len = (zoneIds_.size() - beg);
if (len > 0)
{
SubList<label>(zoneIds_, len, beg) = max(0, zones.size()-1);
}
} }
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher) bool Foam::sampledMeshedSurface::update(const meshSearch& meshSearcher)
{ {
// Global numbering for cells/faces
// - only used to uniquely identify local elements
globalIndex globalCells(onBoundary() ? mesh().nFaces() : mesh().nCells());
// Find the cells the triangles of the surface are in. // Find the cells the triangles of the surface are in.
// Does approximation by looking at the face centres only // Does approximation by looking at the face centres only
const pointField& fc = surface_.faceCentres(); const pointField& fc = surface_.faceCentres();
List<nearInfo> nearest(fc.size()); List<nearInfo> nearest(fc.size(), nearInfo(GREAT, labelMax));
// Global numbering for cells/faces - only used to uniquely identify local
// elements
globalIndex globalCells(onBoundary() ? mesh().nFaces() : mesh().nCells());
for (nearInfo& near : nearest)
{
near.first() = GREAT;
near.second() = labelMax;
}
if (sampleSource_ == cells) if (sampleSource_ == cells)
{ {
@ -155,17 +178,16 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
const indexedOctree<treeDataCell>& cellTree = meshSearcher.cellTree(); const indexedOctree<treeDataCell>& cellTree = meshSearcher.cellTree();
forAll(fc, triI) forAll(fc, facei)
{ {
pointIndexHit nearInfo = cellTree.findNearest const point& pt = fc[facei];
(
fc[triI], pointIndexHit info = cellTree.findNearest(pt, sqr(GREAT));
sqr(GREAT)
); if (info.hit())
if (nearInfo.hit())
{ {
nearest[triI].first() = magSqr(nearInfo.hitPoint()-fc[triI]); nearest[facei].first() = magSqr(info.hitPoint()-pt);
nearest[triI].second() = globalCells.toGlobal(nearInfo.index()); nearest[facei].second() = globalCells.toGlobal(info.index());
} }
} }
} }
@ -173,17 +195,19 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
{ {
// Search for cell containing point // Search for cell containing point
const indexedOctree<treeDataCell>& cellTree = meshSearcher.cellTree(); const auto& cellTree = meshSearcher.cellTree();
forAll(fc, triI) forAll(fc, facei)
{ {
if (cellTree.bb().contains(fc[triI])) const point& pt = fc[facei];
if (cellTree.bb().contains(pt))
{ {
const label index = cellTree.findInside(fc[triI]); const label index = cellTree.findInside(pt);
if (index != -1) if (index != -1)
{ {
nearest[triI].first() = 0.0; nearest[facei].first() = 0;
nearest[triI].second() = globalCells.toGlobal(index); nearest[facei].second() = globalCells.toGlobal(index);
} }
} }
} }
@ -193,23 +217,22 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
// Search for nearest boundaryFace // Search for nearest boundaryFace
//- Search on all non-coupled boundary faces //- Search on all non-coupled boundary faces
const indexedOctree<treeDataFace>& bTree = const auto& bndTree = meshSearcher.nonCoupledBoundaryTree();
meshSearcher.nonCoupledBoundaryTree();
forAll(fc, triI) forAll(fc, facei)
{ {
pointIndexHit nearInfo = bTree.findNearest const point& pt = fc[facei];
(
fc[triI], pointIndexHit info = bndTree.findNearest(pt, sqr(GREAT));
sqr(GREAT)
); if (info.hit())
if (nearInfo.hit())
{ {
nearest[triI].first() = magSqr(nearInfo.hitPoint()-fc[triI]); nearest[facei].first() = magSqr(info.hitPoint()-pt);
nearest[triI].second() = globalCells.toGlobal nearest[facei].second() =
( globalCells.toGlobal
bTree.shapes().faceLabels()[nearInfo.index()] (
); bndTree.shapes().faceLabels()[info.index()]
);
} }
} }
} }
@ -223,20 +246,20 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
labelList cellOrFaceLabels(fc.size(), -1); labelList cellOrFaceLabels(fc.size(), -1);
label nFound = 0; bitSet facesToSubset(fc.size());
forAll(nearest, triI)
forAll(nearest, facei)
{ {
if (nearest[triI].second() == labelMax) const label index = nearest[facei].second();
if (index == labelMax)
{ {
// Not found on any processor. How to map? // Not found on any processor. How to map?
} }
else if (globalCells.isLocal(nearest[triI].second())) else if (globalCells.isLocal(index))
{ {
cellOrFaceLabels[triI] = globalCells.toLocal cellOrFaceLabels[facei] = globalCells.toLocal(index);
( facesToSubset.set(facei);
nearest[triI].second()
);
nFound++;
} }
} }
@ -244,206 +267,59 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
if (debug) if (debug)
{ {
Pout<< "Local out of faces:" << cellOrFaceLabels.size() Pout<< "Local out of faces:" << cellOrFaceLabels.size()
<< " keeping:" << nFound << endl; << " keeping:" << facesToSubset.count() << endl;
}
// Now subset the surface.
// Done manually in case the original had non-compact point numbering
const triSurface& s = surface_;
// Compact to original triangle
labelList faceMap(s.size());
// Compact to original points
labelList pointMap(s.points().size());
// From original point to compact points
labelList reversePointMap(s.points().size(), -1);
// Handle region-wise sorting (makes things slightly more complicated)
zoneIds_.setSize(s.size(), -1);
// Better not to use triSurface::sortedZones here,
// since we'll sort ourselves
// Get zone/region sizes used, store under the original region Id
Map<label> zoneSizes;
// Recover region names from the input surface
Map<word> zoneNames;
{
const geometricSurfacePatchList& patches = s.patches();
forAll(patches, patchi)
{
zoneNames.set
(
patchi,
(
patches[patchi].name().empty()
? geometricSurfacePatch::defaultName(patchi)
: patches[patchi].name()
)
);
zoneSizes.set(patchi, 0);
}
} }
{ // Subset the surface
label newPointi = 0; meshedSurface& s = static_cast<meshedSurface&>(*this);
label newFacei = 0;
forAll(s, facei) labelList pointMap;
{ labelList faceMap;
if (cellOrFaceLabels[facei] != -1)
{
const triSurface::FaceType& f = s[facei];
const label regionid = f.region();
auto fnd = zoneSizes.find(regionid); s = surface_.subsetMesh(facesToSubset, pointMap, faceMap);
if (fnd.found())
{
++(*fnd);
}
else
{
// This shouldn't happen
zoneSizes.insert(regionid, 1);
zoneNames.set
(
regionid,
geometricSurfacePatch::defaultName(regionid)
);
}
// Store new faces compact // Ensure zoneIds_ are indeed correct
faceMap[newFacei] = facei; setZoneMap();
zoneIds_[newFacei] = regionid;
++newFacei;
// Renumber face points
for (const label labi : f)
{
if (reversePointMap[labi] == -1)
{
pointMap[newPointi] = labi;
reversePointMap[labi] = newPointi++;
}
}
}
}
// Trim
faceMap.setSize(newFacei);
zoneIds_.setSize(newFacei);
pointMap.setSize(newPointi);
}
// Assign start/size (and name) to the newZones
// re-use the lookup to map (zoneId => zoneI)
surfZoneList zoneLst(zoneSizes.size());
label start = 0;
label zoneI = 0;
forAllIters(zoneSizes, iter)
{
// No negative regionids, so Map<label> usually sorts properly
const label regionid = iter.key();
word name;
auto fnd = zoneNames.cfind(regionid);
if (fnd.found())
{
name = *fnd;
}
if (name.empty())
{
name = geometricSurfacePatch::defaultName(regionid);
}
zoneLst[zoneI] = surfZone
(
name,
0, // initialize with zero size
start,
zoneI
);
// Adjust start for the next zone and save (zoneId => zoneI) mapping
start += iter();
iter() = zoneI++;
}
// At this stage:
// - faceMap to map the (unsorted) compact to original triangle
// - zoneIds for the next sorting
// - zoneSizes contains region -> count information
// Rebuild the faceMap for the sorted order
labelList sortedFaceMap(faceMap.size());
forAll(zoneIds_, facei)
{
const label zonei = zoneIds_[facei];
label sortedFacei = zoneLst[zonei].start() + zoneLst[zonei].size()++;
sortedFaceMap[sortedFacei] = faceMap[facei];
}
// zoneIds are now simply flat values
setZoneMap(zoneLst, zoneIds_);
// Replace the faceMap with the properly sorted face map
faceMap.transfer(sortedFaceMap);
// This is currently only partially useful
if (keepIds_) if (keepIds_)
{ {
originalIds_ = faceMap; originalIds_ = faceMap;
} }
else
{
originalIds_.clear();
}
// Subset cellOrFaceLabels (for compact faces) // Subset cellOrFaceLabels (for compact faces)
cellOrFaceLabels = labelUIndList(cellOrFaceLabels, faceMap)(); cellOrFaceLabels = labelUIndList(cellOrFaceLabels, faceMap)();
// Store any face per point (without using pointFaces())
labelList pointToFace(pointMap.size());
// Create faces and points for subsetted surface
faceList& surfFaces = this->storedFaces();
surfFaces.setSize(faceMap.size());
this->storedZones().transfer(zoneLst);
forAll(faceMap, facei)
{
face& f = surfFaces[facei];
f = s[faceMap[facei]]; // Copy original face
inplaceRenumber(reversePointMap, f); // renumber point ids
for (const label labi : f)
{
pointToFace[labi] = facei;
}
}
this->storedPoints() = pointField(s.points(), pointMap);
if (debug)
{
print(Pout);
Pout<< endl;
}
// Collect the samplePoints and sampleElements // Collect the samplePoints and sampleElements
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (sampledSurface::interpolate()) if (sampledSurface::interpolate())
{ {
samplePoints_.setSize(pointMap.size()); // With point interpolation
sampleElements_.setSize(pointMap.size(), -1);
samplePoints_.resize(pointMap.size());
sampleElements_.resize(pointMap.size(), -1);
// Store any face per point (without using pointFaces())
labelList pointToFace(std::move(pointMap));
forAll(s, facei)
{
const face& f = s[facei];
for (const label labi : f)
{
pointToFace[labi] = facei;
}
}
if (sampleSource_ == cells) if (sampleSource_ == cells)
{ {
@ -453,7 +329,9 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
forAll(points(), pointi) forAll(points(), pointi)
{ {
const point& pt = points()[pointi]; const point& pt = points()[pointi];
label celli = cellOrFaceLabels[pointToFace[pointi]];
const label celli = cellOrFaceLabels[pointToFace[pointi]];
sampleElements_[pointi] = celli; sampleElements_[pointi] = celli;
// Check if point inside cell // Check if point inside cell
@ -472,14 +350,15 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
else else
{ {
// Find nearest point on faces of cell // Find nearest point on faces of cell
const cell& cFaces = mesh().cells()[celli];
scalar minDistSqr = VGREAT; scalar minDistSqr = VGREAT;
forAll(cFaces, i) for (const label facei : mesh().cells()[celli])
{ {
const face& f = mesh().faces()[cFaces[i]]; const face& f = mesh().faces()[facei];
pointHit info = f.nearestPoint(pt, mesh().points()); pointHit info = f.nearestPoint(pt, mesh().points());
if (info.distance() < minDistSqr) if (info.distance() < minDistSqr)
{ {
minDistSqr = info.distance(); minDistSqr = info.distance();
@ -497,7 +376,9 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
forAll(points(), pointi) forAll(points(), pointi)
{ {
const point& pt = points()[pointi]; const point& pt = points()[pointi];
label celli = cellOrFaceLabels[pointToFace[pointi]];
const label celli = cellOrFaceLabels[pointToFace[pointi]];
sampleElements_[pointi] = celli; sampleElements_[pointi] = celli;
samplePoints_[pointi] = pt; samplePoints_[pointi] = pt;
} }
@ -511,7 +392,9 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
forAll(points(), pointi) forAll(points(), pointi)
{ {
const point& pt = points()[pointi]; const point& pt = points()[pointi];
label facei = cellOrFaceLabels[pointToFace[pointi]];
const label facei = cellOrFaceLabels[pointToFace[pointi]];
sampleElements_[pointi] = facei; sampleElements_[pointi] = facei;
samplePoints_[pointi] = mesh().faces()[facei].nearestPoint samplePoints_[pointi] = mesh().faces()[facei].nearestPoint
( (
@ -591,7 +474,7 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh Foam::sampledMeshedSurface::sampledMeshedSurface
( (
const word& name, const word& name,
const polyMesh& mesh, const polyMesh& mesh,
@ -617,7 +500,7 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
{} {}
Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh Foam::sampledMeshedSurface::sampledMeshedSurface
( (
const word& name, const word& name,
const polyMesh& mesh, const polyMesh& mesh,
@ -628,7 +511,7 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
MeshStorage(), MeshStorage(),
surfaceName_ surfaceName_
( (
triSurface::findFile meshedSurface::findFile
( (
selectReadIO(dict.get<word>("surface"), mesh.time()), selectReadIO(dict.get<word>("surface"), mesh.time()),
dict dict
@ -651,13 +534,13 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::sampledTriSurfaceMesh::needsUpdate() const bool Foam::sampledMeshedSurface::needsUpdate() const
{ {
return needsUpdate_; return needsUpdate_;
} }
bool Foam::sampledTriSurfaceMesh::expire() bool Foam::sampledMeshedSurface::expire()
{ {
// already marked as expired // already marked as expired
if (needsUpdate_) if (needsUpdate_)
@ -678,7 +561,7 @@ bool Foam::sampledTriSurfaceMesh::expire()
} }
bool Foam::sampledTriSurfaceMesh::update() bool Foam::sampledMeshedSurface::update()
{ {
if (!needsUpdate_) if (!needsUpdate_)
{ {
@ -724,7 +607,7 @@ bool Foam::sampledTriSurfaceMesh::update()
} }
bool Foam::sampledTriSurfaceMesh::update(const treeBoundBox& bb) bool Foam::sampledMeshedSurface::update(const treeBoundBox& bb)
{ {
if (!needsUpdate_) if (!needsUpdate_)
{ {
@ -738,7 +621,7 @@ bool Foam::sampledTriSurfaceMesh::update(const treeBoundBox& bb)
} }
Foam::tmp<Foam::scalarField> Foam::sampledTriSurfaceMesh::sample Foam::tmp<Foam::scalarField> Foam::sampledMeshedSurface::sample
( (
const interpolation<scalar>& sampler const interpolation<scalar>& sampler
) const ) const
@ -747,7 +630,7 @@ Foam::tmp<Foam::scalarField> Foam::sampledTriSurfaceMesh::sample
} }
Foam::tmp<Foam::vectorField> Foam::sampledTriSurfaceMesh::sample Foam::tmp<Foam::vectorField> Foam::sampledMeshedSurface::sample
( (
const interpolation<vector>& sampler const interpolation<vector>& sampler
) const ) const
@ -756,7 +639,7 @@ Foam::tmp<Foam::vectorField> Foam::sampledTriSurfaceMesh::sample
} }
Foam::tmp<Foam::sphericalTensorField> Foam::sampledTriSurfaceMesh::sample Foam::tmp<Foam::sphericalTensorField> Foam::sampledMeshedSurface::sample
( (
const interpolation<sphericalTensor>& sampler const interpolation<sphericalTensor>& sampler
) const ) const
@ -765,7 +648,7 @@ Foam::tmp<Foam::sphericalTensorField> Foam::sampledTriSurfaceMesh::sample
} }
Foam::tmp<Foam::symmTensorField> Foam::sampledTriSurfaceMesh::sample Foam::tmp<Foam::symmTensorField> Foam::sampledMeshedSurface::sample
( (
const interpolation<symmTensor>& sampler const interpolation<symmTensor>& sampler
) const ) const
@ -774,7 +657,7 @@ Foam::tmp<Foam::symmTensorField> Foam::sampledTriSurfaceMesh::sample
} }
Foam::tmp<Foam::tensorField> Foam::sampledTriSurfaceMesh::sample Foam::tmp<Foam::tensorField> Foam::sampledMeshedSurface::sample
( (
const interpolation<tensor>& sampler const interpolation<tensor>& sampler
) const ) const
@ -783,7 +666,7 @@ Foam::tmp<Foam::tensorField> Foam::sampledTriSurfaceMesh::sample
} }
Foam::tmp<Foam::scalarField> Foam::sampledTriSurfaceMesh::interpolate Foam::tmp<Foam::scalarField> Foam::sampledMeshedSurface::interpolate
( (
const interpolation<scalar>& interpolator const interpolation<scalar>& interpolator
) const ) const
@ -792,7 +675,7 @@ Foam::tmp<Foam::scalarField> Foam::sampledTriSurfaceMesh::interpolate
} }
Foam::tmp<Foam::vectorField> Foam::sampledTriSurfaceMesh::interpolate Foam::tmp<Foam::vectorField> Foam::sampledMeshedSurface::interpolate
( (
const interpolation<vector>& interpolator const interpolation<vector>& interpolator
) const ) const
@ -800,7 +683,7 @@ Foam::tmp<Foam::vectorField> Foam::sampledTriSurfaceMesh::interpolate
return sampleOnPoints(interpolator); return sampleOnPoints(interpolator);
} }
Foam::tmp<Foam::sphericalTensorField> Foam::sampledTriSurfaceMesh::interpolate Foam::tmp<Foam::sphericalTensorField> Foam::sampledMeshedSurface::interpolate
( (
const interpolation<sphericalTensor>& interpolator const interpolation<sphericalTensor>& interpolator
) const ) const
@ -809,7 +692,7 @@ Foam::tmp<Foam::sphericalTensorField> Foam::sampledTriSurfaceMesh::interpolate
} }
Foam::tmp<Foam::symmTensorField> Foam::sampledTriSurfaceMesh::interpolate Foam::tmp<Foam::symmTensorField> Foam::sampledMeshedSurface::interpolate
( (
const interpolation<symmTensor>& interpolator const interpolation<symmTensor>& interpolator
) const ) const
@ -818,7 +701,7 @@ Foam::tmp<Foam::symmTensorField> Foam::sampledTriSurfaceMesh::interpolate
} }
Foam::tmp<Foam::tensorField> Foam::sampledTriSurfaceMesh::interpolate Foam::tmp<Foam::tensorField> Foam::sampledMeshedSurface::interpolate
( (
const interpolation<tensor>& interpolator const interpolation<tensor>& interpolator
) const ) const
@ -827,9 +710,9 @@ Foam::tmp<Foam::tensorField> Foam::sampledTriSurfaceMesh::interpolate
} }
void Foam::sampledTriSurfaceMesh::print(Ostream& os) const void Foam::sampledMeshedSurface::print(Ostream& os) const
{ {
os << "sampledTriSurfaceMesh: " << name() << " :" os << "meshedSurface: " << name() << " :"
<< " surface:" << surfaceName_ << " surface:" << surfaceName_
<< " faces:" << faces().size() << " faces:" << faces().size()
<< " points:" << points().size() << " points:" << points().size()

View File

@ -25,11 +25,11 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::sampledTriSurfaceMesh Foam::sampledMeshedSurface
Description Description
A sampledSurface from a meshed surface. A sampledSurface from a meshed surface.
It samples on the points/faces of the triSurface. It samples on the points/faces of the meshed surface.
- it either samples cells or (non-coupled) boundary faces - it either samples cells or (non-coupled) boundary faces
@ -69,36 +69,35 @@ Usage
Example of function object partial specification: Example of function object partial specification:
\verbatim \verbatim
surfaces surfaces
( {
surface1 surface1
{ {
type sampledTriSurfaceMesh; type meshedSurface;
surface something.obj; surface something.obj;
source cells; source cells;
} }
); }
\endverbatim \endverbatim
Where the sub-entries comprise: Where the sub-entries comprise:
\table \table
Property | Description | Required | Default Property | Description | Required | Default
type | sampledTriSurfaceMesh | yes | type | meshedSurface | yes |
surface | surface name in triSurface/ | yes | surface | surface name in triSurface/ | yes |
source | cells/insideCells/boundaryFaces | yes | source | cells/insideCells/boundaryFaces | yes |
keepIds | pass through id numbering | no | false keepIds | pass through id numbering | no | false
\endtable \endtable
SourceFiles SourceFiles
sampledTriSurfaceMesh.C sampledMeshedSurface.C
sampledTriSurfaceMeshTemplates.C sampledMeshedSurfaceTemplates.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef sampledTriSurfaceMesh_H #ifndef sampledMeshedSurface_H
#define sampledTriSurfaceMesh_H #define sampledMeshedSurface_H
#include "sampledSurface.H" #include "sampledSurface.H"
#include "triSurface.H"
#include "MeshedSurface.H" #include "MeshedSurface.H"
#include "MeshedSurfacesFwd.H" #include "MeshedSurfacesFwd.H"
@ -107,14 +106,14 @@ SourceFiles
namespace Foam namespace Foam
{ {
class treeDataFace; // Forward Declarations
class meshSearch; class meshSearch;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class sampledTriSurfaceMesh Declaration Class sampledMeshedSurface Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class sampledTriSurfaceMesh class sampledMeshedSurface
: :
public sampledSurface, public sampledSurface,
public meshedSurface public meshedSurface
@ -134,7 +133,7 @@ private:
typedef meshedSurface MeshStorage; typedef meshedSurface MeshStorage;
// Private data // Private Data
static const Enum<samplingSource> samplingSourceNames_; static const Enum<samplingSource> samplingSourceNames_;
@ -142,7 +141,7 @@ private:
word surfaceName_; word surfaceName_;
//- Surface to sample on //- Surface to sample on
const triSurface surface_; const meshedSurface surface_;
//- Whether to sample internal cell values or boundary values //- Whether to sample internal cell values or boundary values
const samplingSource sampleSource_; const samplingSource sampleSource_;
@ -169,6 +168,9 @@ private:
// Private Member Functions // Private Member Functions
//- Set zoneIds list based on the surfZone information
void setZoneMap();
//- Sample volume field onto surface faces //- Sample volume field onto surface faces
template<class Type> template<class Type>
tmp<Field<Type>> sampleOnFaces tmp<Field<Type>> sampleOnFaces
@ -187,14 +189,14 @@ private:
public: public:
//- Runtime type information //- Declare type-name, virtual type (with debug switch)
TypeName("sampledTriSurfaceMesh"); TypeName("sampledMeshedSurface");
// Constructors // Constructors
//- Construct from components //- Construct from components
sampledTriSurfaceMesh sampledMeshedSurface
( (
const word& name, const word& name,
const polyMesh& mesh, const polyMesh& mesh,
@ -203,7 +205,7 @@ public:
); );
//- Construct from dictionary //- Construct from dictionary
sampledTriSurfaceMesh sampledMeshedSurface
( (
const word& name, const word& name,
const polyMesh& mesh, const polyMesh& mesh,
@ -212,19 +214,11 @@ public:
//- Destructor //- Destructor
virtual ~sampledTriSurfaceMesh() = default; virtual ~sampledMeshedSurface() = default;
// Member Functions // Member Functions
//- Set new zoneIds list based on the surfZoneList information
static void setZoneMap
(
const surfZoneList& zoneLst,
labelList& zoneIds
);
//- Does the surface need an update? //- Does the surface need an update?
virtual bool needsUpdate() const; virtual bool needsUpdate() const;
@ -378,7 +372,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository #ifdef NoRepository
#include "sampledTriSurfaceMeshTemplates.C" #include "sampledMeshedSurfaceTemplates.C"
#endif #endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -25,26 +25,36 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "sampledTriSurfaceMeshNormal.H" #include "sampledMeshedSurfaceNormal.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(sampledTriSurfaceMeshNormal, 0); defineTypeNameAndDebug(sampledMeshedSurfaceNormal, 0);
addToRunTimeSelectionTable // Use shorter name only
addNamedToRunTimeSelectionTable
( (
sampledSurface, sampledSurface,
sampledTriSurfaceMeshNormal, sampledMeshedSurfaceNormal,
word word,
meshedSurfaceNormal
);
// Compatibility name (1912)
addNamedToRunTimeSelectionTable
(
sampledSurface,
sampledMeshedSurfaceNormal,
word,
sampledTriSurfaceMeshNormal
); );
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledTriSurfaceMeshNormal::sampledTriSurfaceMeshNormal Foam::sampledMeshedSurfaceNormal::sampledMeshedSurfaceNormal
( (
const word& name, const word& name,
const polyMesh& mesh, const polyMesh& mesh,
@ -52,25 +62,25 @@ Foam::sampledTriSurfaceMeshNormal::sampledTriSurfaceMeshNormal
const samplingSource sampleSource const samplingSource sampleSource
) )
: :
sampledTriSurfaceMesh(name, mesh, surfaceName, sampleSource) sampledMeshedSurface(name, mesh, surfaceName, sampleSource)
{} {}
Foam::sampledTriSurfaceMeshNormal::sampledTriSurfaceMeshNormal Foam::sampledMeshedSurfaceNormal::sampledMeshedSurfaceNormal
( (
const word& name, const word& name,
const polyMesh& mesh, const polyMesh& mesh,
const dictionary& dict const dictionary& dict
) )
: :
sampledTriSurfaceMesh(name, mesh, dict) sampledMeshedSurface(name, mesh, dict)
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::Field<Foam::vector>> Foam::tmp<Foam::Field<Foam::vector>>
Foam::sampledTriSurfaceMeshNormal::sample Foam::sampledMeshedSurfaceNormal::sample
( (
const interpolation<vector>& sampler const interpolation<vector>& sampler
) const ) const
@ -81,7 +91,7 @@ Foam::sampledTriSurfaceMeshNormal::sample
( (
0, 0,
meshedSurface::faceNormals() meshedSurface::faceNormals()
&sampledTriSurfaceMesh::sample(sampler) &sampledMeshedSurface::sample(sampler)
); );
return tvalues; return tvalues;
@ -89,7 +99,7 @@ Foam::sampledTriSurfaceMeshNormal::sample
Foam::tmp<Foam::Field<Foam::vector>> Foam::tmp<Foam::Field<Foam::vector>>
Foam::sampledTriSurfaceMeshNormal::interpolate Foam::sampledMeshedSurfaceNormal::interpolate
( (
const interpolation<vector>& interpolator const interpolation<vector>& interpolator
) const ) const
@ -103,7 +113,7 @@ Foam::sampledTriSurfaceMeshNormal::interpolate
( (
0, 0,
allNormals allNormals
&sampledTriSurfaceMesh::interpolate(interpolator) &sampledMeshedSurface::interpolate(interpolator)
); );
return tvalues; return tvalues;

View File

@ -24,10 +24,10 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::sampledTriSurfaceMeshNormal Foam::sampledMeshedSurfaceNormal
Description Description
Variant of sampledTriSurfaceMesh that samples the surface-normal component Variant of sampledMeshedSurface that samples the surface-normal component
of a vector field. of a vector field.
Returns a vector field with the value in the first component and sets Returns a vector field with the value in the first component and sets
@ -39,38 +39,38 @@ Usage
Example of function object partial specification: Example of function object partial specification:
\verbatim \verbatim
surfaces surfaces
( {
surface1 surface1
{ {
type sampledTriSurfaceMeshNormal; type sampledMeshedSurfaceNormal;
surface something.obj; surface something.obj;
source cells; source cells;
} }
); }
\endverbatim \endverbatim
Where the sub-entries comprise: Where the sub-entries comprise:
\table \table
Property | Description | Required | Default Property | Description | Required | Default
type | sampledTriSurfaceMeshNormal | yes | type | meshedSurfaceNormal | yes |
surface | surface name in triSurface/ | yes | surface | surface name in triSurface/ | yes |
source | cells/insideCells/boundaryFaces | yes | source | cells/insideCells/boundaryFaces | yes |
keepIds | pass through id numbering | no | false keepIds | pass through id numbering | no | false
\endtable \endtable
SeeAlso SeeAlso
Foam::sampledTriSurfaceMesh Foam::sampledMeshedSurface
SourceFiles SourceFiles
sampledTriSurfaceMeshNormal.C sampledMeshedSurfaceNormal.C
sampledTriSurfaceMeshNormalTemplates.C sampledMeshedSurfaceNormalTemplates.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef sampledTriSurfaceMeshNormal_H #ifndef sampledMeshedSurfaceNormal_H
#define sampledTriSurfaceMeshNormal_H #define sampledMeshedSurfaceNormal_H
#include "sampledTriSurfaceMesh.H" #include "sampledMeshedSurface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -78,23 +78,23 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class sampledTriSurfaceMeshNormal Declaration Class sampledMeshedSurfaceNormal Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class sampledTriSurfaceMeshNormal class sampledMeshedSurfaceNormal
: :
public sampledTriSurfaceMesh public sampledMeshedSurface
{ {
public: public:
//- Runtime type information //- Runtime type information
TypeName("sampledTriSurfaceMeshNormal"); TypeName("sampledMeshedSurfaceNormal");
// Constructors // Constructors
//- Construct from components //- Construct from components
sampledTriSurfaceMeshNormal sampledMeshedSurfaceNormal
( (
const word& name, const word& name,
const polyMesh& mesh, const polyMesh& mesh,
@ -103,7 +103,7 @@ public:
); );
//- Construct from dictionary //- Construct from dictionary
sampledTriSurfaceMeshNormal sampledMeshedSurfaceNormal
( (
const word& name, const word& name,
const polyMesh& mesh, const polyMesh& mesh,
@ -112,7 +112,7 @@ public:
//- Destructor //- Destructor
virtual ~sampledTriSurfaceMeshNormal() = default; virtual ~sampledMeshedSurfaceNormal() = default;
// Member Functions // Member Functions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2018 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,13 +26,13 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "sampledTriSurfaceMesh.H" #include "sampledMeshedSurface.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::tmp<Foam::Field<Type>>
Foam::sampledTriSurfaceMesh::sampleOnFaces Foam::sampledMeshedSurface::sampleOnFaces
( (
const interpolation<Type>& sampler const interpolation<Type>& sampler
) const ) const
@ -95,7 +95,7 @@ Foam::sampledTriSurfaceMesh::sampleOnFaces
template<class Type> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::tmp<Foam::Field<Type>>
Foam::sampledTriSurfaceMesh::sampleOnPoints Foam::sampledMeshedSurface::sampleOnPoints
( (
const interpolation<Type>& interpolator const interpolation<Type>& interpolator
) const ) const

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -72,7 +72,7 @@ Description
( (
f0surf f0surf
{ {
type sampledTriSurfaceMesh; type meshedSurface;
surface f0surf.obj; surface f0surf.obj;
source cells; source cells;

View File

@ -23,7 +23,7 @@ sampled
_sampleMesh _sampleMesh
{ {
type sampledTriSurfaceMesh; type meshedSurface;
source cells; source cells;
store true; store true;
} }

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 | | \\ / O peration | Version: v2006 |
| \\ / A nd | Website: www.openfoam.com | | \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -168,7 +168,7 @@ nonWeightedAreaAverage
name sampledTriSurf; name sampledTriSurf;
sampledSurfaceDict sampledSurfaceDict
{ {
type sampledTriSurfaceMesh; type meshedSurface;
surface angledPlane.obj; surface angledPlane.obj;
source insideCells; source insideCells;
interpolate true; interpolate true;