37 namespace sampledSurfaces
70 if (
y.first() <
x.first())
84 > Foam::sampledSurfaces::triSurface::samplingSourceNames_
95 Foam::sampledSurfaces::triSurface::nonCoupledboundaryTree()
const
100 if (!boundaryTreePtr_.valid())
114 bndFaces[bndI++] = pp.start()+i;
118 bndFaces.setSize(bndI);
122 overallBb = overallBb.extend(1
e-4);
124 boundaryTreePtr_.reset
126 new indexedOctree<treeDataFace>
142 return boundaryTreePtr_();
148 const meshSearch& meshSearcher
153 const pointField& fc = surface_.faceCentres();
155 List<nearInfo> nearest(fc.size());
159 globalIndex globalCells
161 (sampleSource_ ==
cells || sampleSource_ == insideCells)
168 nearest[i].first() = great;
172 if (sampleSource_ ==
cells)
176 const indexedOctree<treeDataCell>& cellTree = meshSearcher.cellTree();
188 nearest[triI].second() = globalCells.toGlobal(
nearInfo.index());
192 else if (sampleSource_ == insideCells)
196 const indexedOctree<treeDataCell>& cellTree = meshSearcher.cellTree();
200 if (cellTree.bb().contains(fc[triI]))
202 label index = cellTree.findInside(fc[triI]);
205 nearest[triI].first() = 0.0;
206 nearest[triI].second() = globalCells.toGlobal(index);
215 const indexedOctree<treeDataFace>& bTree = nonCoupledboundaryTree();
227 nearest[triI].second() = globalCells.toGlobal
229 bTree.shapes().faceLabels()[
nearInfo.index()]
242 labelList cellOrFaceLabels(fc.size(), -1);
251 else if (globalCells.isLocal(nearest[triI].second()))
253 cellOrFaceLabels[triI] = globalCells.toLocal
264 Pout<<
"Local out of faces:" << cellOrFaceLabels.size()
265 <<
" keeping:" << nFound <<
endl;
278 labelList reversePointMap(
s.points().size(), -1);
286 if (cellOrFaceLabels[facei] != -1)
293 if (reversePointMap[
f[fp]] == -1)
307 cellOrFaceLabels = UIndirectList<label>(cellOrFaceLabels,
faceMap)();
313 faceList& faces = this->storedFaces();
320 reversePointMap[
f[0]],
321 reversePointMap[
f[1]],
322 reversePointMap[
f[2]]
324 faces[i] = newF.triFaceFace();
328 pointToFace[newF[fp]] = i;
332 this->storedPoints() =
pointField(
s.points(), pointMap);
347 samplePoints_.setSize(pointMap.size());
348 sampleElements_.setSize(pointMap.size(), -1);
350 if (sampleSource_ ==
cells)
358 label celli = cellOrFaceLabels[pointToFace[pointi]];
359 sampleElements_[pointi] = celli;
367 sampleElements_[pointi],
368 meshSearcher.decompMode()
372 samplePoints_[pointi] = pt;
379 scalar minDistSqr = vGreat;
385 if (info.distance() < minDistSqr)
387 minDistSqr = info.distance();
388 samplePoints_[pointi] = info.rawPoint();
394 else if (sampleSource_ == insideCells)
402 label celli = cellOrFaceLabels[pointToFace[pointi]];
403 sampleElements_[pointi] = celli;
404 samplePoints_[pointi] = pt;
416 label facei = cellOrFaceLabels[pointToFace[pointi]];
417 sampleElements_[pointi] = facei;
418 samplePoints_[pointi] =
mesh().
faces()[facei].nearestPoint
437 samplePoints_.
clear();
438 sampleElements_.transfer(cellOrFaceLabels);
446 OBJstream str(
mesh().time().path()/
"surfaceToMesh.obj");
448 Info<<
"Dumping correspondence from local surface (points or faces)"
449 <<
" to mesh (cells or faces) to " << str.name() <<
endl;
453 if (sampleSource_ ==
cells || sampleSource_ == insideCells)
455 forAll(samplePoints_, pointi)
457 const label celli = sampleElements_[pointi];
464 samplePoints_[pointi],
465 mesh().cellCentres()[celli]
472 forAll(samplePoints_, pointi)
474 const label facei = sampleElements_[pointi];
481 samplePoints_[pointi],
482 mesh().faceCentres()[facei]
490 if (sampleSource_ ==
cells || sampleSource_ == insideCells)
492 forAll(sampleElements_, triI)
494 const label celli = sampleElements_[triI];
501 mesh().cellCentres()[celli]
508 forAll(sampleElements_, triI)
510 const label facei = sampleElements_[triI];
517 mesh().faceCentres()[facei]
525 needsUpdate_ =
false;
537 const word& surfaceName,
547 mesh.time().constant(),
555 sampleSource_(sampleSource),
574 dict.lookup(
"surface"),
575 mesh.time().constant(),
583 sampleSource_(samplingSourceNames_[
dict.lookup(
"source")]),
595 const word& sampleSourceName
604 mesh.time().constant(),
613 sampleSource_(samplingSourceNames_[sampleSourceName]),
645 boundaryTreePtr_.clear();
646 sampleElements_.clear();
647 samplePoints_.clear();
664 return update(meshSearcher);
678 return update(meshSearcher);
688 return sampleField(vField);
698 return sampleField(vField);
707 return sampleField(vField);
717 return sampleField(vField);
727 return sampleField(vField);
737 return interpolateField(interpolator);
747 return interpolateField(interpolator);
756 return interpolateField(interpolator);
766 return interpolateField(interpolator);
776 return interpolateField(interpolator);
782 os <<
"triSurface: " <<
name() <<
" :"
783 <<
" surface:" << surface_.objectRegistry::name()
784 <<
" faces:" << faces().size()
785 <<
" 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...
void clear()
Clear the list, i.e. set size to zero.
face FaceType
Face type used.
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,...
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Abstract base class for interpolation.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Mesh consisting of general polyhedral cells.
virtual const faceList & faces() const
Return raw faces.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const cellList & cells() const
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 triSurface. It samples on the points/triangles of the triSurface....
triSurface(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.
virtual ~triSurface()
Destructor.
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.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const fvPatchList & patches
addBackwardCompatibleToRunTimeSelectionTable(sampledSurface, triSurface, word, triSurfaceMesh, "triSurfaceMesh")
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.
PointIndexHit< point > pointIndexHit
Ostream & endl(Ostream &os)
Add newline and flush stream.
line< point, const point & > linePointRef
Line using referred points.
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)
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
triangle< point, const point & > triPointRef
prefixOSstream Pout(cout, "Pout")
void magSqr(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
static const label labelMax