mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: sampledTriSurfaceMesh: added sampling only inside triangles
This commit is contained in:
@ -46,13 +46,14 @@ namespace Foam
|
||||
);
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<sampledTriSurfaceMesh::samplingSource, 2>::names[] =
|
||||
const char* NamedEnum<sampledTriSurfaceMesh::samplingSource, 3>::names[] =
|
||||
{
|
||||
"cells",
|
||||
"insideCells",
|
||||
"boundaryFaces"
|
||||
};
|
||||
|
||||
const NamedEnum<sampledTriSurfaceMesh::samplingSource, 2>
|
||||
const NamedEnum<sampledTriSurfaceMesh::samplingSource, 3>
|
||||
sampledTriSurfaceMesh::samplingSourceNames_;
|
||||
|
||||
|
||||
@ -147,7 +148,7 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
|
||||
// elements
|
||||
globalIndex globalCells
|
||||
(
|
||||
sampleSource_ == cells
|
||||
(sampleSource_ == cells || sampleSource_ == insideCells)
|
||||
? mesh().nCells()
|
||||
: mesh().nFaces()
|
||||
);
|
||||
@ -178,6 +179,25 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sampleSource_ == insideCells)
|
||||
{
|
||||
// Search for cell containing point
|
||||
|
||||
const indexedOctree<treeDataCell>& cellTree = meshSearcher.cellTree();
|
||||
|
||||
forAll(fc, triI)
|
||||
{
|
||||
if (cellTree.bb().contains(fc[triI]))
|
||||
{
|
||||
label index = cellTree.findInside(fc[triI]);
|
||||
if (index != -1)
|
||||
{
|
||||
nearest[triI].first() = 0.0;
|
||||
nearest[triI].second() = globalCells.toGlobal(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Search for nearest boundaryFace
|
||||
@ -364,6 +384,19 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sampleSource_ == insideCells)
|
||||
{
|
||||
// samplePoints_ : per surface point a location inside the cell
|
||||
// sampleElements_ : per surface point the cell
|
||||
|
||||
forAll(points(), pointI)
|
||||
{
|
||||
const point& pt = points()[pointI];
|
||||
label cellI = cellOrFaceLabels[pointToFace[pointI]];
|
||||
sampleElements_[pointI] = cellI;
|
||||
samplePoints_[pointI] = pt;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// samplePoints_ : per surface point a location on the boundary
|
||||
@ -388,6 +421,9 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
|
||||
// if sampleSource_ == cells:
|
||||
// samplePoints_ : n/a
|
||||
// sampleElements_ : per surface triangle the cell
|
||||
// if sampleSource_ == insideCells:
|
||||
// samplePoints_ : n/a
|
||||
// sampleElements_ : -1 or per surface triangle the cell
|
||||
// else:
|
||||
// samplePoints_ : n/a
|
||||
// sampleElements_ : per surface triangle the boundary face
|
||||
@ -406,7 +442,7 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
|
||||
|
||||
if (sampledSurface::interpolate())
|
||||
{
|
||||
if (sampleSource_ == cells)
|
||||
if (sampleSource_ == cells || sampleSource_ == insideCells)
|
||||
{
|
||||
forAll(samplePoints_, pointI)
|
||||
{
|
||||
@ -443,7 +479,7 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sampleSource_ == cells)
|
||||
if (sampleSource_ == cells || sampleSource_ == insideCells)
|
||||
{
|
||||
forAll(sampleElements_, triI)
|
||||
{
|
||||
|
||||
@ -30,7 +30,7 @@ Description
|
||||
|
||||
- it either samples cells or (non-coupled) boundary faces
|
||||
|
||||
- 4 different modes:
|
||||
- 6 different modes:
|
||||
- source=cells, interpolate=false:
|
||||
finds per triangle centre the nearest cell centre and uses its value
|
||||
- source=cells, interpolate=true
|
||||
@ -40,6 +40,12 @@ Description
|
||||
the boundary of the cell (to make sure interpolateCellPoint
|
||||
gets a valid location)
|
||||
|
||||
- source=insideCells, interpolate=false:
|
||||
finds per triangle centre the cell containing it and uses its value.
|
||||
Trims triangles outside mesh.
|
||||
- source=insideCells, interpolate=true
|
||||
Per surface point interpolate cell containing it.
|
||||
|
||||
- source=boundaryFaces, interpolate=false:
|
||||
finds per triangle centre the nearest point on the boundary
|
||||
(uncoupled faces only) and uses the value (or 0 if the nearest
|
||||
@ -88,7 +94,8 @@ public:
|
||||
enum samplingSource
|
||||
{
|
||||
cells,
|
||||
boundaryFaces
|
||||
insideCells,
|
||||
boundaryFaces,
|
||||
};
|
||||
|
||||
private:
|
||||
@ -99,7 +106,7 @@ private:
|
||||
|
||||
// Private data
|
||||
|
||||
static const NamedEnum<samplingSource, 2> samplingSourceNames_;
|
||||
static const NamedEnum<samplingSource, 3> samplingSourceNames_;
|
||||
|
||||
//- Surface to sample on
|
||||
const triSurfaceMesh surface_;
|
||||
|
||||
@ -38,7 +38,7 @@ Foam::sampledTriSurfaceMesh::sampleField
|
||||
tmp<Field<Type> > tvalues(new Field<Type>(sampleElements_.size()));
|
||||
Field<Type>& values = tvalues();
|
||||
|
||||
if (sampleSource_ == cells)
|
||||
if (sampleSource_ == cells || sampleSource_ == insideCells)
|
||||
{
|
||||
// Sample cells
|
||||
|
||||
@ -94,7 +94,7 @@ Foam::sampledTriSurfaceMesh::interpolateField
|
||||
tmp<Field<Type> > tvalues(new Field<Type>(sampleElements_.size()));
|
||||
Field<Type>& values = tvalues();
|
||||
|
||||
if (sampleSource_ == cells)
|
||||
if (sampleSource_ == cells || sampleSource_ == insideCells)
|
||||
{
|
||||
// Sample cells.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user