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

View File

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

View File

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

View File

@ -26,7 +26,7 @@ License
\*---------------------------------------------------------------------------*/
#include "sampledTriSurfaceMesh.H"
#include "sampledMeshedSurface.H"
#include "meshSearch.H"
#include "Tuple2.H"
#include "globalIndex.H"
@ -39,9 +39,9 @@ License
const Foam::Enum
<
Foam::sampledTriSurfaceMesh::samplingSource
Foam::sampledMeshedSurface::samplingSource
>
Foam::sampledTriSurfaceMesh::samplingSourceNames_
Foam::sampledMeshedSurface::samplingSourceNames_
({
{ samplingSource::cells, "cells" },
{ samplingSource::insideCells, "insideCells" },
@ -51,12 +51,22 @@ Foam::sampledTriSurfaceMesh::samplingSourceNames_
namespace Foam
{
defineTypeNameAndDebug(sampledTriSurfaceMesh, 0);
addToRunTimeSelectionTable
defineTypeNameAndDebug(sampledMeshedSurface, 0);
// Use shorter name only
addNamedToRunTimeSelectionTable
(
sampledSurface,
sampledTriSurfaceMesh,
word
sampledMeshedSurface,
word,
meshedSurface
);
// Compatibility name (1912)
addNamedToRunTimeSelectionTable
(
sampledSurface,
sampledMeshedSurface,
word,
sampledTriSurfaceMesh
);
//- Private class for finding nearest
@ -104,50 +114,63 @@ inline static IOobject selectReadIO(const word& name, const Time& runTime)
} // End namespace Foam
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::sampledTriSurfaceMesh::setZoneMap
(
const surfZoneList& zoneLst,
labelList& zoneIds
)
void Foam::sampledMeshedSurface::setZoneMap()
{
label sz = 0;
for (const surfZone& zn : zoneLst)
{
sz += zn.size();
}
zoneIds.resize(sz);
// Ensure zoneIds_ are correctly populated
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
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 * * * * * * * * * * * //
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.
// Does approximation by looking at the face centres only
const pointField& fc = surface_.faceCentres();
List<nearInfo> nearest(fc.size());
// 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;
}
List<nearInfo> nearest(fc.size(), nearInfo(GREAT, labelMax));
if (sampleSource_ == cells)
{
@ -155,17 +178,16 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
const indexedOctree<treeDataCell>& cellTree = meshSearcher.cellTree();
forAll(fc, triI)
forAll(fc, facei)
{
pointIndexHit nearInfo = cellTree.findNearest
(
fc[triI],
sqr(GREAT)
);
if (nearInfo.hit())
const point& pt = fc[facei];
pointIndexHit info = cellTree.findNearest(pt, sqr(GREAT));
if (info.hit())
{
nearest[triI].first() = magSqr(nearInfo.hitPoint()-fc[triI]);
nearest[triI].second() = globalCells.toGlobal(nearInfo.index());
nearest[facei].first() = magSqr(info.hitPoint()-pt);
nearest[facei].second() = globalCells.toGlobal(info.index());
}
}
}
@ -173,17 +195,19 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
{
// 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)
{
nearest[triI].first() = 0.0;
nearest[triI].second() = globalCells.toGlobal(index);
nearest[facei].first() = 0;
nearest[facei].second() = globalCells.toGlobal(index);
}
}
}
@ -193,23 +217,22 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
// Search for nearest boundaryFace
//- Search on all non-coupled boundary faces
const indexedOctree<treeDataFace>& bTree =
meshSearcher.nonCoupledBoundaryTree();
const auto& bndTree = meshSearcher.nonCoupledBoundaryTree();
forAll(fc, triI)
forAll(fc, facei)
{
pointIndexHit nearInfo = bTree.findNearest
(
fc[triI],
sqr(GREAT)
);
if (nearInfo.hit())
const point& pt = fc[facei];
pointIndexHit info = bndTree.findNearest(pt, sqr(GREAT));
if (info.hit())
{
nearest[triI].first() = magSqr(nearInfo.hitPoint()-fc[triI]);
nearest[triI].second() = globalCells.toGlobal
(
bTree.shapes().faceLabels()[nearInfo.index()]
);
nearest[facei].first() = magSqr(info.hitPoint()-pt);
nearest[facei].second() =
globalCells.toGlobal
(
bndTree.shapes().faceLabels()[info.index()]
);
}
}
}
@ -223,20 +246,20 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
labelList cellOrFaceLabels(fc.size(), -1);
label nFound = 0;
forAll(nearest, triI)
bitSet facesToSubset(fc.size());
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?
}
else if (globalCells.isLocal(nearest[triI].second()))
else if (globalCells.isLocal(index))
{
cellOrFaceLabels[triI] = globalCells.toLocal
(
nearest[triI].second()
);
nFound++;
cellOrFaceLabels[facei] = globalCells.toLocal(index);
facesToSubset.set(facei);
}
}
@ -244,206 +267,59 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
if (debug)
{
Pout<< "Local out of faces:" << cellOrFaceLabels.size()
<< " keeping:" << nFound << 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);
}
<< " keeping:" << facesToSubset.count() << endl;
}
{
label newPointi = 0;
label newFacei = 0;
// Subset the surface
meshedSurface& s = static_cast<meshedSurface&>(*this);
forAll(s, facei)
{
if (cellOrFaceLabels[facei] != -1)
{
const triSurface::FaceType& f = s[facei];
const label regionid = f.region();
labelList pointMap;
labelList faceMap;
auto fnd = zoneSizes.find(regionid);
if (fnd.found())
{
++(*fnd);
}
else
{
// This shouldn't happen
zoneSizes.insert(regionid, 1);
zoneNames.set
(
regionid,
geometricSurfacePatch::defaultName(regionid)
);
}
s = surface_.subsetMesh(facesToSubset, pointMap, faceMap);
// Store new faces compact
faceMap[newFacei] = facei;
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);
// Ensure zoneIds_ are indeed correct
setZoneMap();
// This is currently only partially useful
if (keepIds_)
{
originalIds_ = faceMap;
}
else
{
originalIds_.clear();
}
// Subset cellOrFaceLabels (for compact faces)
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
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (sampledSurface::interpolate())
{
samplePoints_.setSize(pointMap.size());
sampleElements_.setSize(pointMap.size(), -1);
// With point interpolation
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)
{
@ -453,7 +329,9 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
forAll(points(), pointi)
{
const point& pt = points()[pointi];
label celli = cellOrFaceLabels[pointToFace[pointi]];
const label celli = cellOrFaceLabels[pointToFace[pointi]];
sampleElements_[pointi] = celli;
// Check if point inside cell
@ -472,14 +350,15 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
else
{
// Find nearest point on faces of cell
const cell& cFaces = mesh().cells()[celli];
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());
if (info.distance() < minDistSqr)
{
minDistSqr = info.distance();
@ -497,7 +376,9 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
forAll(points(), pointi)
{
const point& pt = points()[pointi];
label celli = cellOrFaceLabels[pointToFace[pointi]];
const label celli = cellOrFaceLabels[pointToFace[pointi]];
sampleElements_[pointi] = celli;
samplePoints_[pointi] = pt;
}
@ -511,7 +392,9 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
forAll(points(), pointi)
{
const point& pt = points()[pointi];
label facei = cellOrFaceLabels[pointToFace[pointi]];
const label facei = cellOrFaceLabels[pointToFace[pointi]];
sampleElements_[pointi] = facei;
samplePoints_[pointi] = mesh().faces()[facei].nearestPoint
(
@ -591,7 +474,7 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
Foam::sampledMeshedSurface::sampledMeshedSurface
(
const word& name,
const polyMesh& mesh,
@ -617,7 +500,7 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
{}
Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
Foam::sampledMeshedSurface::sampledMeshedSurface
(
const word& name,
const polyMesh& mesh,
@ -628,7 +511,7 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
MeshStorage(),
surfaceName_
(
triSurface::findFile
meshedSurface::findFile
(
selectReadIO(dict.get<word>("surface"), mesh.time()),
dict
@ -651,13 +534,13 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::sampledTriSurfaceMesh::needsUpdate() const
bool Foam::sampledMeshedSurface::needsUpdate() const
{
return needsUpdate_;
}
bool Foam::sampledTriSurfaceMesh::expire()
bool Foam::sampledMeshedSurface::expire()
{
// already marked as expired
if (needsUpdate_)
@ -678,7 +561,7 @@ bool Foam::sampledTriSurfaceMesh::expire()
}
bool Foam::sampledTriSurfaceMesh::update()
bool Foam::sampledMeshedSurface::update()
{
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_)
{
@ -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
@ -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
@ -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
@ -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
@ -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
@ -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
@ -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
@ -800,7 +683,7 @@ Foam::tmp<Foam::vectorField> Foam::sampledTriSurfaceMesh::interpolate
return sampleOnPoints(interpolator);
}
Foam::tmp<Foam::sphericalTensorField> Foam::sampledTriSurfaceMesh::interpolate
Foam::tmp<Foam::sphericalTensorField> Foam::sampledMeshedSurface::interpolate
(
const interpolation<sphericalTensor>& interpolator
) 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
@ -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
@ -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_
<< " faces:" << faces().size()
<< " points:" << points().size()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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