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);
437 OBJstream str(mesh().time().path()/
"surfaceToMesh.obj");
439 Info<<
"Dumping correspondence from local surface (points or faces)"
440 <<
" to mesh (cells or faces) to " << str.name() <<
endl;
444 if (sampleSource_ ==
cells || sampleSource_ == insideCells)
446 forAll(samplePoints_, pointi)
448 const label celli = sampleElements_[pointi];
455 samplePoints_[pointi],
456 mesh().cellCentres()[celli]
463 forAll(samplePoints_, pointi)
465 const label facei = sampleElements_[pointi];
472 samplePoints_[pointi],
473 mesh().faceCentres()[facei]
481 if (sampleSource_ ==
cells || sampleSource_ == insideCells)
483 forAll(sampleElements_, triI)
485 const label celli = sampleElements_[triI];
492 mesh().cellCentres()[celli]
499 forAll(sampleElements_, triI)
501 const label facei = sampleElements_[triI];
508 mesh().faceCentres()[facei]
516 needsUpdate_ =
false;
528 const word& surfaceName,
538 mesh.time().constant(),
546 sampleSource_(sampleSource),
565 dict.lookup(
"surface"),
566 mesh.time().constant(),
574 sampleSource_(samplingSourceNames_[
dict.lookup(
"source")]),
586 const word& sampleSourceName
595 mesh.time().constant(),
604 sampleSource_(samplingSourceNames_[sampleSourceName]),
636 boundaryTreePtr_.clear();
637 sampleElements_.clear();
638 samplePoints_.clear();
655 return update(meshSearcher);
669 return update(meshSearcher);
679 return sampleField(vField);
689 return sampleField(vField);
698 return sampleField(vField);
708 return sampleField(vField);
718 return sampleField(vField);
728 return interpolateField(interpolator);
738 return interpolateField(interpolator);
747 return interpolateField(interpolator);
757 return interpolateField(interpolator);
767 return interpolateField(interpolator);
773 os <<
"triSurfaceMesh: " <<
name() <<
" :"
774 <<
" surface:" << surface_.objectRegistry::name()
775 <<
" faces:" << faces().size()
776 <<
" 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.
line< point, const point & > linePointRef
Line using referred points.
word name(const bool)
Return a word representation of a bool.
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)
triangle< point, const point & > triPointRef
prefixOSstream Pout(cout, "Pout")
static const label labelMax
dimensioned< scalar > magSqr(const dimensioned< Type > &)