Go to the documentation of this file.
45 Foam::discreteSurface::samplingSourceNames_
48 { samplingSource::insideCells,
"insideCells" },
49 { samplingSource::boundaryFaces,
"boundaryFaces" },
61 typedef Tuple2<scalar, label>
nearInfo;
69 if (
y.first() <
x.first())
106 Foam::discreteSurface::nonCoupledboundaryTree()
const
111 if (!boundaryTreePtr_.valid())
124 bndFaces[bndI++] = pp.start()+i;
128 bndFaces.setSize(bndI);
134 overallBb = overallBb.extend(
rndGen, 1
e-4);
135 overallBb.min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
136 overallBb.max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
138 boundaryTreePtr_.reset
140 new indexedOctree<treeDataFace>
156 return *boundaryTreePtr_;
164 const pointField& fc = surface_.faceCentres();
166 List<nearInfo> nearest(fc.size());
170 globalIndex globalCells(onBoundary() ?
mesh().nFaces() :
mesh().nCells());
174 nearest[i].first() = GREAT;
178 if (sampleSource_ ==
cells)
182 const indexedOctree<treeDataCell>& cellTree = meshSearcher.cellTree();
194 nearest[triI].second() = globalCells.toGlobal(
nearInfo.index());
198 else if (sampleSource_ == insideCells)
202 const indexedOctree<treeDataCell>& cellTree = meshSearcher.cellTree();
206 if (cellTree.bb().contains(fc[triI]))
208 const label index = cellTree.findInside(fc[triI]);
211 nearest[triI].first() = 0.0;
212 nearest[triI].second() = globalCells.toGlobal(index);
224 const indexedOctree<treeDataFace>& bTree = nonCoupledboundaryTree();
236 nearest[triI].second() = globalCells.toGlobal
238 bTree.shapes().faceLabels()[
nearInfo.index()]
251 labelList cellOrFaceLabels(fc.size(), -1);
256 if (nearest[triI].second() ==
labelMax)
260 else if (globalCells.isLocal(nearest[triI].second()))
262 cellOrFaceLabels[triI] = globalCells.toLocal
264 nearest[triI].second()
273 Pout<<
"Local out of faces:" << cellOrFaceLabels.size()
274 <<
" keeping:" << nFound <<
endl;
280 const triSurface&
s = surface_;
287 labelList reversePointMap(
s.points().size(), -1);
296 Map<label> zoneSizes;
315 zoneSizes.set(patchi, 0);
326 if (cellOrFaceLabels[facei] != -1)
329 const label regionid =
f.region();
332 if (fnd != zoneSizes.end())
339 zoneSizes.insert(regionid, 1);
349 zoneIds_[newFacei] = regionid;
357 if (reversePointMap[labI] == -1)
368 zoneIds_.setSize(newFacei);
381 const label regionid = iter.key();
385 if (fnd != zoneNames.end())
394 zoneLst[zoneI] = surfZone
418 label zonei = zoneIds_[facei];
419 label sortedFacei = zoneLst[zonei].start() + zoneLst[zonei].size()++;
420 sortedFaceMap[sortedFacei] =
faceMap[facei];
424 setZoneMap(zoneLst, zoneIds_);
427 faceMap.transfer(sortedFaceMap);
441 faceList& surfFaces = this->storedFaces();
442 surfFaces.setSize(
faceMap.size());
444 this->storedZones().transfer(zoneLst);
448 const labelledTri& origF =
s[
faceMap[facei]];
449 face&
f = surfFaces[facei];
453 reversePointMap[origF[0]],
454 reversePointMap[origF[1]],
455 reversePointMap[origF[2]]
460 pointToFace[
f[fp]] = facei;
464 this->storedPoints() =
pointField(
s.points(), pointMap);
478 samplePoints_.setSize(pointMap.size());
479 sampleElements_.setSize(pointMap.size(), -1);
481 if (sampleSource_ ==
cells)
489 label celli = cellOrFaceLabels[pointToFace[pointi]];
490 sampleElements_[pointi] = celli;
498 sampleElements_[pointi],
499 meshSearcher.decompMode()
503 samplePoints_[pointi] = pt;
508 const cell& cFaces =
mesh().
cells()[celli];
510 scalar minDistSqr = VGREAT;
516 if (info.distance() < minDistSqr)
518 minDistSqr = info.distance();
519 samplePoints_[pointi] = info.rawPoint();
525 else if (sampleSource_ == insideCells)
533 label celli = cellOrFaceLabels[pointToFace[pointi]];
534 sampleElements_[pointi] = celli;
535 samplePoints_[pointi] = pt;
547 label facei = cellOrFaceLabels[pointToFace[pointi]];
548 sampleElements_[pointi] = facei;
549 samplePoints_[pointi] =
mesh().
faces()[facei].nearestPoint
568 sampleElements_.
transfer(cellOrFaceLabels);
569 samplePoints_.clear();
576 OFstream str(
mesh().time().
path()/
"surfaceToMesh.obj");
577 Info<<
"Dumping correspondence from local surface (points or faces)"
578 <<
" to mesh (cells or faces) to " << str.name() <<
endl;
590 forAll(samplePoints_, pointi)
598 label elemi = sampleElements_[pointi];
601 str <<
"l " << vertI-2 <<
' ' << vertI-1 <<
' ' << vertI <<
nl;
607 forAll(sampleElements_, triI)
612 label elemi = sampleElements_[triI];
615 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
620 needsUpdate_ =
false;
630 const word& surfaceName,
632 const bool allowInterpolate
637 allowInterpolate_(allowInterpolate),
652 sampleSource_(sampleSource),
666 const bool allowInterpolate
671 allowInterpolate_(allowInterpolate),
690 sampleSource_(samplingSourceNames_.get(
"source",
dict)),
705 const word& sampleSourceName,
706 const bool allowInterpolate
711 allowInterpolate_(allowInterpolate),
727 sampleSource_(samplingSourceNames_[sampleSourceName]),
753 if (interpolate_ ==
b)
758 if (
b && !allowInterpolate_)
788 originalIds_.clear();
789 boundaryTreePtr_.clear();
790 sampleElements_.clear();
791 samplePoints_.clear();
808 surface_.triSurface::points(),
809 surface_.triSurface::meshPoints()
815 const vector span(bb.span());
817 bb.
min() -= 0.5*span;
818 bb.
max() += 0.5*span;
825 return update(meshSearcher);
839 return update(meshSearcher);
846 const word& fieldName,
847 const word& sampleScheme
852 sampleType<scalar>(store, fieldName, sampleScheme)
853 || sampleType<vector>(store, fieldName, sampleScheme)
854 || sampleType<sphericalTensor>(store, fieldName, sampleScheme)
855 || sampleType<symmTensor>(store, fieldName, sampleScheme)
856 || sampleType<tensor>(store, fieldName, sampleScheme)
863 os <<
"discreteSurface:"
864 <<
" surface:" << surface_.objectRegistry::name()
865 <<
" faces:" << this->surfFaces().size()
866 <<
" points:" << this->
points().size()
867 <<
" zoneids:" << this->zoneIds().size();
int debug
Static debugging option.
label start() const
Return start label of this zone in the face list.
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
bool interpolate() const
Interpolation requested for surface.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
typename parent_type::const_iterator const_iterator
Tuple2< scalar, label > nearInfo
Private class for finding nearest.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
A class for handling words, derived from Foam::string.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
A List obtained as a section of another List.
Standard boundBox with extra functionality for use in octree.
const cellList & cells() const
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const point & max() const
Maximum describing the bounding box.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
T lookupOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
static void setZoneMap(const surfZoneList &, labelList &zoneIds)
Set new zoneIds list based on the surfZoneList information.
virtual bool update()
Update the surface as required.
typename parent_type::iterator iterator
discreteSurface(const polyMesh &mesh, const word &surfaceName, const samplingSource sampleSource, const bool allowInterpolate=true)
Construct from components.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Mesh consisting of general polyhedral cells.
const point & min() const
Minimum describing the bounding box.
#define forAll(list, i)
Loop across all elements in list.
Field< vector > vectorField
Specialisation of Field<T> for vector.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
List< geometricSurfacePatch > geometricSurfacePatchList
Registry of regIOobjects.
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Triangulated surface description with patch information.
messageStream Info
Information stream (uses stdout - output is on the master only)
A patch is a list of labels that address the faces in the global face list.
word name(const complex &c)
Return string representation of complex.
void transfer(List< T > &list)
virtual bool needsUpdate() const
Does the surface need an update?
virtual void print(Ostream &os) const
Write information.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
#define forAllIters(container, iter)
Iterate across all elements in the container object.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
label size() const
Return size of this zone in the face list.
PointHit< point > pointHit
Macros for easy insertion into run-time selection tables.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
const boundBox & bounds() const
Return mesh bounding box.
const vectorField & cellCentres() const
virtual const faceList & faces() const
Return raw faces.
const polyMesh & mesh() const
Access to the underlying mesh.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
List< face > faceList
A List of faces.
A surface zone on a MeshedSurface.
label ListType::const_reference const label start
const vectorField & faceCentres() const
Ostream & print(Ostream &os, UIntType value, char off='0', char on='1')
Print 0/1 bits in the (unsigned) integral type.
const dimensionedScalar e
Elementary charge.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
const polyBoundaryMesh & patches
void operator()(nearInfo &x, const nearInfo &y) const
List< surfZone > surfZoneList
static word printf(const char *fmt, const PrimitiveType &val)
Use a printf-style formatter for a primitive.
const Time & time() const
Return the top-level database.
virtual bool sampleAndStore(const objectRegistry &store, const word &fieldName, const word &sampleScheme) const
Sample the volume field onto surface,.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
vector point
Point is a vector.
virtual ~discreteSurface()
Destructor.
void setSize(const label newSize)
Alias for resize(const label)
const word & constant() const
Return constant name.
defineTypeNameAndDebug(combustionModel, 0)
samplingSource
Types of communications.
virtual bool expire()
Mark the surface as needing an update.
UIndirectList< label > labelUIndList
UIndirectList of labels.