45Foam::sampledMeshedSurface::samplingSourceNames_
47 { samplingSource::cells,
"cells" },
48 { samplingSource::insideCells,
"insideCells" },
49 { samplingSource::boundaryFaces,
"boundaryFaces" },
101void Foam::sampledMeshedSurface::setZoneMap()
107 const auto& zones =
s.surfZones();
112 if (zoneIds_.
empty() || zones.size() <= 1)
123 const label len =
min(zones[zonei].
size(), zoneIds_.size() - beg);
126 SubList<label>(zoneIds_, len, beg) = zonei;
133 const label len = (zoneIds_.size() - beg);
137 SubList<label>(zoneIds_, len, beg) =
max(0, zones.size()-1);
153 const pointField& fc = surface_.faceCentres();
159 if (sampleSource_ == samplingSource::cells)
163 const auto& cellTree = meshSearcher.cellTree();
164 const auto& treeData = cellTree.shapes();
168 const point& pt = fc[facei];
169 auto& near = nearest[facei];
175 const label objectIndex = treeData.objectIndex(info.index());
177 near.first() = info.point().distSqr(pt);
178 near.second() = globalCells.toGlobal(objectIndex);
182 else if (sampleSource_ == samplingSource::insideCells)
186 const auto& cellTree = meshSearcher.cellTree();
187 const auto& treeData = cellTree.shapes();
191 const point& pt = fc[facei];
192 auto& near = nearest[facei];
194 if (cellTree.bb().contains(pt))
196 const label index = cellTree.findInside(pt);
200 const label objectIndex = treeData.objectIndex(index);
203 near.second() = globalCells.toGlobal(objectIndex);
213 const auto& bndTree = meshSearcher.nonCoupledBoundaryTree();
214 const auto& treeData = bndTree.shapes();
218 const point& pt = fc[facei];
219 auto& near = nearest[facei];
225 const label objectIndex = treeData.objectIndex(info.index());
227 near.first() = info.point().distSqr(pt);
228 near.second() = globalCells.toGlobal(objectIndex);
239 labelList cellOrFaceLabels(fc.size(), -1);
241 bitSet facesToSubset(fc.size());
245 const auto& near = nearest[facei];
247 const label index = near.second();
254 else if (globalCells.isLocal(index))
256 facesToSubset.set(facei);
259 cellOrFaceLabels[facei] =
261 (near.first() < maxDistanceSqr_)
262 ? globalCells.toLocal(index)
271 Pout<<
"Local out of faces:" << cellOrFaceLabels.size()
272 <<
" keeping:" << facesToSubset.count() <<
endl;
282 s = surface_.subsetMesh(facesToSubset, pointMap,
faceMap);
301 sampleElements_.resize(pointMap.size(), -1);
310 for (
const label labi :
f)
317 if (sampleSource_ == samplingSource::cells)
322 forAll(samplePoints_, pointi)
325 const point pt = samplePoints_[pointi];
327 const label celli = cellOrFaceLabels[
pointToFace[pointi]];
329 sampleElements_[pointi] = celli;
334 && !
mesh().pointInCell(pt, celli, meshSearcher.decompMode())
340 scalar minDistSqr = VGREAT;
342 for (
const label facei :
mesh().
cells()[celli])
353 if (info.distance() < minDistSqr)
355 minDistSqr = info.distance();
356 samplePoints_[pointi] = info.point();
362 else if (sampleSource_ == samplingSource::insideCells)
367 forAll(samplePoints_, pointi)
369 const label celli = cellOrFaceLabels[
pointToFace[pointi]];
371 sampleElements_[pointi] = celli;
380 forAll(samplePoints_, pointi)
382 const point& pt = samplePoints_[pointi];
384 const label facei = cellOrFaceLabels[
pointToFace[pointi]];
386 sampleElements_[pointi] = facei;
390 samplePoints_[pointi] =
412 sampleElements_.transfer(cellOrFaceLabels);
413 samplePoints_.clear();
421 Info<<
"Dumping correspondence from local surface (points or faces)"
422 <<
" to mesh (cells or faces) to " << str.name() <<
endl;
434 forAll(samplePoints_, pointi)
442 label elemi = sampleElements_[pointi];
445 str <<
"l " << vertI-2 <<
' ' << vertI-1 <<
' ' << vertI <<
nl;
451 forAll(sampleElements_, triI)
456 label elemi = sampleElements_[triI];
459 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
464 needsUpdate_ =
false;
475 const word& surfaceName,
476 const samplingSource sampleSource
481 surfaceName_(surfaceName),
487 sampleSource_(sampleSource),
493 maxDistanceSqr_(
Foam::
sqr(GREAT)),
520 sampleSource_(samplingSourceNames_.get(
"source",
dict)),
522 keepIds_(
dict.getOrDefault(
"keepIds", true)),
526 maxDistanceSqr_(
Foam::
sqr(GREAT)),
527 defaultValues_(
dict.subOrEmptyDict(
"defaultValue"))
529 if (
dict.readIfPresent(
"maxDistance", maxDistanceSqr_))
541 maxDistanceSqr_ = Foam::sqr(maxDistanceSqr_);
545 dict.readIfPresent(
"patches", includePatches);
546 includePatches.uniq();
551 if (!includePatches.empty())
553 Info<<
"Subsetting surface " << surfaceName_
554 <<
" to patches: " << flatOutput(includePatches) << nl;
556 const surfZoneList& zones = surface_.surfZones();
558 const labelList zoneIndices
560 stringListOps::findMatching
570 bitSet includeMap(surface_.size());
572 for (const label zonei : zoneIndices)
574 const surfZone& zn = zones[zonei];
575 includeMap.set(zn.range());
578 if (includeMap.none())
581 <<
"Patch selection results in an empty surface"
582 <<
" - ignoring" << nl;
584 else if (!includeMap.all())
586 meshedSurface subSurf(surface_.subsetMesh(includeMap));
591 <<
"Bad surface subset (empty)"
592 <<
" - skip and hope for the best" << nl;
597 surface_.transfer(subSurf);
624 sampleElements_.clear();
625 samplePoints_.clear();
640 treeBoundBox bb(surface_.points(), surface_.meshPoints());
648 bb.grow(0.5*bb.span());
657 <<
"Surface " << surfaceName_
658 <<
" does not overlap bounding box of mesh " <<
mesh().
bounds()
668 return update(meshSearcher);
682 return update(meshSearcher);
691 return sampleOnFaces(sampler);
700 return sampleOnFaces(sampler);
709 return sampleOnFaces(sampler);
718 return sampleOnFaces(sampler);
727 return sampleOnFaces(sampler);
736 return sampleOnPoints(interpolator);
745 return sampleOnPoints(interpolator);
753 return sampleOnPoints(interpolator);
762 return sampleOnPoints(interpolator);
771 return sampleOnPoints(interpolator);
777 os <<
"meshedSurface: " <<
name() <<
" :"
778 <<
" surface:" << surfaceName_;
782 os <<
" faces:" << faces().size()
784 <<
" zoneids:" << zoneIds().size();
Macros for easy insertion into run-time selection tables.
#define addNamedToRunTimeSelectionTable(baseType, thisType, argNames, lookupName)
Add to construction table with 'lookupName' as the key.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label len)
Adjust allocated size of list.
static const List< face > & null() noexcept
const surfZoneList & surfZones() const
Const access to the surface zones.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static void listCombineReduce(UList< T > &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::listReduce with an in-place cop.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
bool empty() const noexcept
True if List is empty (ie, size() is zero).
bool get(const label i) const
void size(const label n)
Older name for setAddressableSize.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void grow(const scalar delta)
Expand box by adjusting min/max by specified amount in each dimension.
bool good() const
Bounding box is non-inverted.
void reset()
Reset to an inverted box.
void inflate(const scalar factor)
Expand box by factor*mag(span) in all dimensions.
vector span() const
The bounding box span (from minimum to maximum).
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A face is a list of labels corresponding to mesh vertices.
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
Abstract base class for volume field interpolation.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
A topoSetFaceSource to select faces with any point or any edge within a given pointSet(s).
Mesh consisting of general polyhedral cells.
virtual const faceList & faces() const
Return raw faces.
const boundBox & bounds() const noexcept
Return mesh bounding box.
const vectorField & faceCentres() const
const vectorField & cellCentres() const
A sampledSurface from a meshed surface. It samples on the points/faces of the meshed surface.
sampledMeshedSurface(const word &name, const polyMesh &mesh, const word &surfaceName, const samplingSource sampleSource)
Construct from components.
virtual void print(Ostream &os, int level=0) const
Print information.
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
virtual const faceList & faces() const
Faces of surface.
virtual const labelList & zoneIds() const
Per-face zone/region information.
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.
samplingSource
Types of sampling regions.
An abstract class for surfaces with sampling.
bool isPointData() const noexcept
Using interpolation to surface points.
sampledSurface(const word &name, std::nullptr_t)
Construct null.
const word & name() const noexcept
Name of surface.
virtual void clearGeom() const
Additional cleanup when clearing the geometry.
const polyMesh & mesh() const noexcept
Access to the underlying mesh.
bool interpolate() const noexcept
Same as isPointData().
A class for managing temporary objects.
Standard boundBox with extra functionality for use in octree.
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
OBJstream os(runTime.globalPath()/outputName)
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))
#define WarningInFunction
Report a warning using Foam::Warning.
Namespace for bounding specifications. At the moment, mostly for tables.
Namespace for handling debugging switches.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
PointHit< point > pointHit
A PointHit with a 3D point.
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
UIndirectList< label > labelUIndList
UIndirectList of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
static IOobject selectReadIO(const word &name, const Time &runTime)
Ostream & endl(Ostream &os)
Add newline and flush stream.
MeshedSurface< face > meshedSurface
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
Operations on lists of strings.
Assign tuple-like container to use the one with the smaller value of first.