ENH: sampledTriSurfaceMesh : only sample non-coupled faces

This commit is contained in:
mattijs
2011-01-26 12:15:46 +00:00
parent 4877156db8
commit e1fd499c30
2 changed files with 95 additions and 6 deletions

View File

@ -76,6 +76,63 @@ namespace Foam
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
const Foam::indexedOctree<Foam::treeDataFace>&
Foam::sampledTriSurfaceMesh::nonCoupledboundaryTree() const
{
// Variant of meshSearch::boundaryTree() that only does non-coupled
// boundary faces.
if (!boundaryTreePtr_.valid())
{
// all non-coupled boundary faces (not just walls)
const polyBoundaryMesh& patches = mesh().boundaryMesh();
labelList bndFaces(mesh().nFaces()-mesh().nInternalFaces());
label bndI = 0;
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
if (!pp.coupled())
{
forAll(pp, i)
{
bndFaces[bndI++] = pp.start()+i;
}
}
}
bndFaces.setSize(bndI);
treeBoundBox overallBb(mesh().points());
Random rndGen(123456);
overallBb = overallBb.extend(rndGen, 1E-4);
overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
boundaryTreePtr_.reset
(
new indexedOctree<treeDataFace>
(
treeDataFace // all information needed to search faces
(
false, // do not cache bb
mesh(),
bndFaces // boundary faces only
),
overallBb, // overall search domain
8, // maxLevel
10, // leafsize
3.0 // duplicity
)
);
}
return boundaryTreePtr_();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
@ -159,6 +216,8 @@ bool Foam::sampledTriSurfaceMesh::expire()
sampledSurface::clearGeom(); sampledSurface::clearGeom();
MeshStorage::clear(); MeshStorage::clear();
boundaryTreePtr_.clear();
sampleElements_.clear(); sampleElements_.clear();
samplePoints_.clear(); samplePoints_.clear();
@ -224,7 +283,10 @@ bool Foam::sampledTriSurfaceMesh::update()
{ {
// Search for nearest boundaryFace // Search for nearest boundaryFace
const indexedOctree<treeDataFace>& bTree = meshSearcher.boundaryTree(); ////- Search on all (including coupled) boundary faces
//const indexedOctree<treeDataFace>& bTree = meshSearcher.boundaryTree()
//- Search on all non-coupled boundary faces
const indexedOctree<treeDataFace>& bTree = nonCoupledboundaryTree();
forAll(fc, triI) forAll(fc, triI)
{ {

View File

@ -28,12 +28,31 @@ Description
A sampledSurface from a triSurfaceMesh. It samples on the points/triangles A sampledSurface from a triSurfaceMesh. It samples on the points/triangles
of the triSurface. of the triSurface.
It samples using the cell nearest to the triangle centre so does - it either samples cells or (non-coupled) boundary faces
not check the cell the centre is actually in ...
In parallel every processor just operates on the part of the surface - 4 different modes:
where the face centres are inside the mesh. It is then up to the - source=cells, interpolate=false:
caller to stitch the partial surfaces together. finds per triangle centre the nearest cell centre and uses its value
- source=cells, interpolate=true
finds per triangle centre the nearest cell centre.
Per surface point checks if this nearest cell is the one containing
point; otherwise projects the point onto the nearest point on
the boundary of the cell (to make sure interpolateCellPoint
gets a valid location)
- 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
is on an empty boundary)
- source=boundaryFaces, interpolate=true:
finds per triangle centre the nearest point on the boundary
(uncoupled faces only).
Per surface point projects the point onto this boundary face
(to make sure interpolateCellPoint gets a valid location)
- since it finds a nearest per triangle each triangle is guaranteed
to be on one processor only. So after stitching (by sampledSurfaces)
the original surface should be complete.
SourceFiles SourceFiles
sampledTriSurfaceMesh.C sampledTriSurfaceMesh.C
@ -52,6 +71,8 @@ SourceFiles
namespace Foam namespace Foam
{ {
class treeDataFace;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class sampledTriSurfaceMesh Declaration Class sampledTriSurfaceMesh Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -88,6 +109,9 @@ private:
//- Track if the surface needs an update //- Track if the surface needs an update
mutable bool needsUpdate_; mutable bool needsUpdate_;
//- Search tree for all non-coupled boundary faces
mutable autoPtr<indexedOctree<treeDataFace> > boundaryTreePtr_;
//- From local surface triangle to mesh cell/face. //- From local surface triangle to mesh cell/face.
labelList sampleElements_; labelList sampleElements_;
@ -97,6 +121,9 @@ private:
// Private Member Functions // Private Member Functions
//- Get tree of all non-coupled boundary faces
const indexedOctree<treeDataFace>& nonCoupledboundaryTree() const;
//- sample field on faces //- sample field on faces
template <class Type> template <class Type>
tmp<Field<Type> > sampleField tmp<Field<Type> > sampleField