37 namespace sampledSurfaces
55 if (
y.first() <
x.first())
80 > Foam::sampledSurfaces::triSurfaceMesh::samplingSourceNames_;
86 Foam::sampledSurfaces::triSurfaceMesh::nonCoupledboundaryTree()
const
91 if (!boundaryTreePtr_.valid())
105 bndFaces[bndI++] = pp.
start()+i;
109 bndFaces.setSize(bndI);
113 overallBb = overallBb.extend(1
e-4);
115 boundaryTreePtr_.reset
117 new indexedOctree<treeDataFace>
133 return boundaryTreePtr_();
139 const meshSearch& meshSearcher
144 const pointField& fc = surface_.faceCentres();
146 List<nearInfo> nearest(fc.size());
150 globalIndex globalCells
152 (sampleSource_ ==
cells || sampleSource_ == insideCells)
159 nearest[i].first() = great;
163 if (sampleSource_ ==
cells)
167 const indexedOctree<treeDataCell>& cellTree = meshSearcher.cellTree();
179 nearest[triI].second() = globalCells.toGlobal(
nearInfo.index());
183 else if (sampleSource_ == insideCells)
187 const indexedOctree<treeDataCell>& cellTree = meshSearcher.cellTree();
191 if (cellTree.bb().contains(fc[triI]))
193 label index = cellTree.findInside(fc[triI]);
196 nearest[triI].first() = 0.0;
197 nearest[triI].second() = globalCells.toGlobal(index);
206 const indexedOctree<treeDataFace>& bTree = nonCoupledboundaryTree();
218 nearest[triI].second() = globalCells.toGlobal
220 bTree.shapes().faceLabels()[
nearInfo.index()]
233 labelList cellOrFaceLabels(fc.size(), -1);
242 else if (globalCells.isLocal(nearest[triI].second()))
244 cellOrFaceLabels[triI] = globalCells.toLocal
255 Pout<<
"Local out of faces:" << cellOrFaceLabels.size()
256 <<
" keeping:" << nFound <<
endl;
262 const triSurface&
s = surface_;
269 labelList reversePointMap(
s.points().size(), -1);
277 if (cellOrFaceLabels[facei] != -1)
284 if (reversePointMap[
f[fp]] == -1)
298 cellOrFaceLabels = UIndirectList<label>(cellOrFaceLabels,
faceMap)();
304 faceList& faces = this->storedFaces();
311 reversePointMap[
f[0]],
312 reversePointMap[
f[1]],
313 reversePointMap[
f[2]]
315 faces[i] = newF.triFaceFace();
319 pointToFace[newF[fp]] = i;
323 this->storedPoints() =
pointField(
s.points(), pointMap);
338 samplePoints_.setSize(pointMap.size());
339 sampleElements_.setSize(pointMap.size(), -1);
341 if (sampleSource_ ==
cells)
349 label celli = cellOrFaceLabels[pointToFace[pointi]];
350 sampleElements_[pointi] = celli;
358 sampleElements_[pointi],
359 meshSearcher.decompMode()
363 samplePoints_[pointi] = pt;
368 const cell& cFaces = mesh().cells()[celli];
370 scalar minDistSqr = vGreat;
374 const face&
f = mesh().faces()[cFaces[i]];
376 if (info.distance() < minDistSqr)
378 minDistSqr = info.distance();
379 samplePoints_[pointi] = info.rawPoint();
385 else if (sampleSource_ == insideCells)
393 label celli = cellOrFaceLabels[pointToFace[pointi]];
394 sampleElements_[pointi] = celli;
395 samplePoints_[pointi] = pt;
407 label facei = cellOrFaceLabels[pointToFace[pointi]];
408 sampleElements_[pointi] = facei;
409 samplePoints_[pointi] = mesh().faces()[facei].nearestPoint
428 samplePoints_.clear();
429 sampleElements_.transfer(cellOrFaceLabels);
436 OFstream str(mesh().time().path()/
"surfaceToMesh.obj");
437 Info<<
"Dumping correspondence from local surface (points or faces)"
438 <<
" to mesh (cells or faces) to " << str.name() <<
endl;
443 if (sampleSource_ ==
cells || sampleSource_ == insideCells)
445 forAll(samplePoints_, pointi)
453 label celli = sampleElements_[pointi];
456 str <<
"l " << vertI-2 <<
' ' << vertI-1 <<
' ' << vertI
462 forAll(samplePoints_, pointi)
470 label facei = sampleElements_[pointi];
473 str <<
"l " << vertI-2 <<
' ' << vertI-1 <<
' ' << vertI
480 if (sampleSource_ ==
cells || sampleSource_ == insideCells)
482 forAll(sampleElements_, triI)
487 label celli = sampleElements_[triI];
490 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
495 forAll(sampleElements_, triI)
500 label facei = sampleElements_[triI];
503 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
510 needsUpdate_ =
false;
521 const word& surfaceName,
531 mesh.time().constant(),
539 sampleSource_(sampleSource),
558 dict.lookup(
"surface"),
559 mesh.time().constant(),
567 sampleSource_(samplingSourceNames_[
dict.lookup(
"source")]),
579 const word& sampleSourceName
588 mesh.time().constant(),
597 sampleSource_(samplingSourceNames_[sampleSourceName]),
629 boundaryTreePtr_.clear();
630 sampleElements_.clear();
631 samplePoints_.clear();
648 return update(meshSearcher);
662 return update(meshSearcher);
672 return sampleField(vField);
682 return sampleField(vField);
691 return sampleField(vField);
701 return sampleField(vField);
711 return sampleField(vField);
721 return interpolateField(interpolator);
731 return interpolateField(interpolator);
740 return interpolateField(interpolator);
750 return interpolateField(interpolator);
760 return interpolateField(interpolator);
766 os <<
"triSurfaceMesh: " <<
name() <<
" :"
767 <<
" surface:" << surface_.objectRegistry::name()
768 <<
" faces:" << faces().size()
769 <<
" points:" <<
points().size();
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Initialise the NamedEnum HashTable from the static list of names.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
std::remove_reference< ::Foam::List< labelledTri > >::type::value_type FaceType
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
A 2-tuple for storing two objects of different types.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Abstract base class for interpolation.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
A patch is a list of labels that address the faces in the global face list.
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
label start() const
Return start label of this patch in the polyMesh face list.
An abstract class for surfaces with sampling.
virtual void clearGeom() const
bool interpolate() const
Interpolation requested for surface.
const polyMesh & mesh() const
Access to the underlying mesh.
void operator()(nearInfo &x, const nearInfo &y) const
A sampledSurface from a triSurfaceMesh. It samples on the points/triangles of the triSurface....
virtual ~triSurfaceMesh()
Destructor.
triSurfaceMesh(const word &name, const polyMesh &mesh, const word &surfaceName, const samplingSource sampleSource)
Construct from components.
samplingSource
Types of communications.
virtual tmp< scalarField > sample(const volScalarField &) const
Sample field on surface.
virtual bool expire()
Mark the surface as needing an update.
virtual bool needsUpdate() const
Does the surface need an update?
virtual bool update()
Update the surface as required.
virtual void print(Ostream &) const
Write.
virtual const pointField & points() const
Points of surface.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
A class for managing temporary objects.
Standard boundBox + extra functionality for use in octree.
Triangulated surface description with patch information.
A class for handling words, derived from string.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const fvPatchList & patches
Tuple2< scalar, label > nearInfo
Private class for finding nearest.
defineTypeNameAndDebug(cutPlane, 0)
addToRunTimeSelectionTable(sampledSurface, cutPlane, word)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList second(const UList< labelPair > &p)
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
PointHit< point > pointHit
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
prefixOSstream Pout(cout, "Pout")
static const label labelMax
word name(const complex &)
Return a string representation of a complex.
dimensioned< scalar > magSqr(const dimensioned< Type > &)