45 Foam::sampledMeshedSurface::samplingSourceNames_
48 { samplingSource::insideCells,
"insideCells" },
49 { samplingSource::boundaryFaces,
"boundaryFaces" },
101 void 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);
149 globalIndex globalCells(onBoundary() ?
mesh().nFaces() :
mesh().nCells());
153 const pointField& fc = surface_.faceCentres();
156 typedef Tuple2<scalar, label> nearInfo;
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);
304 labelList pointToFace(std::move(pointMap));
308 const face&
f =
s[facei];
310 for (
const label labi :
f)
312 pointToFace[labi] = facei;
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();
420 OFstream str(
mesh().time().
path()/
"surfaceToMesh.obj");
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_);
544 wordRes includePatches;
545 dict.readIfPresent(
"patches", includePatches);
546 includePatches.uniq();
551 if (!includePatches.empty())
553 Info<<
"Subsetting surface " << surfaceName_
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())
591 <<
"Bad surface subset (empty)" 592 <<
" - skip and hope for the best" <<
nl;
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()
661 bb.reset(
mesh().bounds().centre());
662 bb.grow(1
e-6*
mesh().bounds().span());
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();
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search...
void size(const label n)
Older name for setAddressableSize.
bool interpolate() const noexcept
Same as isPointData()
void resize(const label len)
Adjust allocated size of list.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
An abstract class for surfaces with sampling.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
UIndirectList< label > labelUIndList
UIndirectList of labels.
virtual void clear()
Clear all storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
const cellList & cells() const
Operations on lists of strings.
Ignore writing from objectRegistry::writeObject()
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual bool expire()
Mark the surface as needing an update.
Macros for easy insertion into run-time selection tables.
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
#define forAll(list, i)
Loop across all elements in list.
static IOobject selectReadIO(const word &name, const Time &runTime)
samplingSource
Types of sampling regions.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
virtual void clearGeom() const
Additional cleanup when clearing the geometry.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
MeshedSurface< face > meshedSurface
virtual void print(Ostream &os, int level=0) const
Print information.
labelList findMatching(const StringListType &input, const wordRes::filter &pred, AccessOp aop=identityOp())
Return ids for items with matching names.
MeshedSurface subsetMesh(const UList< bool > &include, labelList &pointMap, labelList &faceMap) const
Return a new surface subsetted on the selected faces.
virtual const faceList & faces() const
Return raw faces.
sampledMeshedSurface(const word &name, const polyMesh &mesh, const word &surfaceName, const samplingSource sampleSource)
Construct from components.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
const vectorField & cellCentres() const
An Ostream is an abstract base class for all output systems (streams, files, token lists...
const word & constant() const noexcept
Return constant name.
virtual bool needsUpdate() const
Does the surface need an update?
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
defineTypeNameAndDebug(combustionModel, 0)
const vectorField & faceCentres() const
label size() const
The surface size is the number of faces.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
virtual bool update()
Update the surface as required.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
List< surfZone > surfZoneList
List of surfZone.
void transfer(pointField &pointLst, List< Face > &faceLst)
Transfer the components.
Standard boundBox with extra functionality for use in octree.
messageStream Info
Information stream (stdout output on master, null elsewhere)
const boundBox & bounds() const noexcept
Return mesh bounding box.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
A class for managing temporary objects.
const surfZoneList & surfZones() const
Const access to the surface zones.
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))
Defines the attributes of an object for which implicit objectRegistry management is supported...
void grow(const scalar delta)
Expand box by adjusting min/max by specified amount in each dimension.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Do not request registration (bool: false)
PointHit< point > pointHit
A PointHit with a 3D point.
bool isPointData() const noexcept
Using interpolation to surface points.
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Combines List elements. After completion all processors have the same data.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.