Go to the documentation of this file.
63 { sampleMode::NEARESTCELL,
"nearestCell" },
64 { sampleMode::NEARESTPATCHFACE,
"nearestPatchFace" },
65 { sampleMode::NEARESTPATCHFACEAMI,
"nearestPatchFaceAMI" },
66 { sampleMode::NEARESTPATCHPOINT,
"nearestPatchPoint" },
67 { sampleMode::NEARESTFACE,
"nearestFace" },
68 { sampleMode::NEARESTONLYCELL,
"nearestOnlyCell" },
78 { offsetMode::UNIFORM,
"uniform" },
79 { offsetMode::NONUNIFORM,
"nonuniform" },
80 { offsetMode::NORMAL,
"normal" },
94 (void)
mesh.tetBasePtIs();
106 polyMesh::FACE_DIAG_TRIS
126 globalFc[Pstream::myProcNo()] = facePoints;
127 Pstream::gatherList(globalFc);
128 Pstream::scatterList(globalFc);
130 patchFc = ListListOps::combine<pointField>
139 globalSamples[Pstream::myProcNo()] = samplePoints(facePoints);
140 Pstream::gatherList(globalSamples);
141 Pstream::scatterList(globalSamples);
143 samples = ListListOps::combine<pointField>
152 globalFaces[Pstream::myProcNo()] =
identity(patch_.size());
154 Pstream::gatherList(globalFaces);
155 Pstream::scatterList(globalFaces);
157 patchFaces = ListListOps::combine<labelList>
166 nPerProc[Pstream::myProcNo()] = patch_.size();
167 Pstream::gatherList(nPerProc);
168 Pstream::scatterList(nPerProc);
170 patchFaceProcs.
setSize(patchFaces.size());
175 for (
label i = 0; i < nPerProc[proci]; i++)
177 patchFaceProcs[sampleI++] = proci;
205 if (samplePatch_.size() && samplePatch_ !=
"none")
208 <<
"No need to supply a patch name when in "
223 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
224 nearest[sampleI].second().second() = Pstream::myProcNo();
228 const point& cc =
mesh.cellCentres()[celli];
236 nearest[sampleI].second().first() =
magSqr(cc-sample);
237 nearest[sampleI].second().second() = Pstream::myProcNo();
243 case NEARESTONLYCELL:
245 if (samplePatch_.size() && samplePatch_ !=
"none")
248 <<
"No need to supply a patch name when in "
259 nearest[sampleI].first() = tree.findNearest(sample,
sqr(GREAT));
260 nearest[sampleI].second().first() =
magSqr
262 nearest[sampleI].first().hitPoint()
265 nearest[sampleI].second().second() = Pstream::myProcNo();
270 case NEARESTPATCHFACE:
280 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
281 nearest[sampleI].second().second() = Pstream::myProcNo();
297 patchBb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
298 patchBb.max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
327 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
328 nearest[sampleI].second().second() =
336 nearest[sampleI].second().second() =
344 case NEARESTPATCHPOINT:
354 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
355 nearest[sampleI].second().second() = Pstream::myProcNo();
369 patchBb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
370 patchBb.max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
398 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
399 nearest[sampleI].second().second() =
407 nearest[sampleI].second().second() =
417 if (samplePatch().size() && samplePatch() !=
"none")
420 <<
"No need to supply a patch name when in "
436 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
437 nearest[sampleI].second().second() = Pstream::myProcNo();
441 const point& fc =
mesh.faceCentres()[facei];
449 nearest[sampleI].second().first() =
magSqr(fc-sample);
450 nearest[sampleI].second().second() = Pstream::myProcNo();
456 case NEARESTPATCHFACEAMI:
471 Pstream::listCombineGather(nearest,
nearestEqOp());
472 Pstream::listCombineScatter(nearest);
478 <<
"mesh " << sampleRegion() <<
" : " <<
endl;
482 label proci = nearest[sampleI].second().second();
483 label localI = nearest[sampleI].first().index();
485 Info<<
" " << sampleI <<
" coord:"<<
samples[sampleI]
486 <<
" found on processor:" << proci
487 <<
" in local cell/face/point:" << localI
488 <<
" with location:" << nearest[sampleI].first().rawPoint()
496 sampleLocations.setSize(
samples.size());
500 if (!nearest[sampleI].first().hit())
502 sampleProcs[sampleI] = -1;
503 sampleIndices[sampleI] = -1;
508 sampleProcs[sampleI] = nearest[sampleI].second().second();
509 sampleIndices[sampleI] = nearest[sampleI].first().index();
510 sampleLocations[sampleI] = nearest[sampleI].first().hitPoint();
518 static bool hasWarned =
false;
543 bool coincident = (
gAverage(
mag(d)) <= ROOTVSMALL);
545 if (sampleMyself && coincident)
548 <<
"Invalid offset " << d <<
endl
549 <<
"Offset is the vector added to the patch face centres to"
550 <<
" find the patch face supplying the data." <<
endl
551 <<
"Setting it to " << d
552 <<
" on the same patch, on the same region"
553 <<
" will find the faces themselves which does not make sense"
554 <<
" for anything but testing." <<
endl
587 forAll(sampleProcs, sampleI)
589 if (sampleProcs[sampleI] == -1)
601 <<
"Did not find " << nNotFound
602 <<
" out of " << sampleProcs.size() <<
" total samples."
603 <<
" Sampling these on owner cell centre instead." <<
endl
608 <<
". Suppressing further warnings from " <<
type() <<
endl;
617 forAll(sampleProcs, sampleI)
619 if (sampleProcs[sampleI] == -1)
676 Pout<<
"Dumping mapping as lines from patch faceCentres to"
677 <<
" sampled cell/faceCentres/points to file " << str.
name()
688 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
704 constructMap[proci] =
labelUIndList(patchFaces, constructMap[proci]);
723 forAll(constructMap, proci)
735 <<
" patchface " << facei
736 <<
" is assigned to more than once."
751 <<
" patchface " << facei
752 <<
" is never assigned to."
763 const word surfType(surfDict_.lookupOrDefault<
word>(
"type",
"none"));
765 if (!surfPtr_.valid() && surfType !=
"none")
767 word surfName(surfDict_.lookupOrDefault(
"name", patch_.name()));
803 const polyPatch& nbr = samplePolyPatch();
821 OFstream os(patch_.name() +
"_neighbourPatch-org.obj");
824 OFstream osN(patch_.name() +
"_neighbourPatch-trans.obj");
827 OFstream osO(patch_.name() +
"_ownerPatch.obj");
867 token firstToken(is);
876 else if (firstToken.
wordToken() ==
"nonuniform")
879 if (
fld.size() != size)
882 <<
"size " <<
fld.size()
883 <<
" is not equal to the given value of " << size
890 <<
"Expected keyword 'uniform' or 'nonuniform', found "
898 <<
"Expected keyword 'uniform' or 'nonuniform', "
899 "assuming List format for backwards compatibility."
900 "Foam version 2.0." <<
endl;
918 sampleRegion_(patch_.boundaryMesh().mesh().name()),
919 mode_(NEARESTPATCHFACE),
922 offsetMode_(UNIFORM),
924 offsets_(pp.size(), offset_),
926 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
938 const word& sampleRegion,
940 const word& samplePatch,
945 sampleRegion_(sampleRegion),
947 samplePatch_(samplePatch),
949 offsetMode_(NONUNIFORM),
953 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
965 const word& sampleRegion,
967 const word& samplePatch,
972 sampleRegion_(sampleRegion),
974 samplePatch_(samplePatch),
976 offsetMode_(UNIFORM),
980 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
992 const word& sampleRegion,
994 const word& samplePatch,
999 sampleRegion_(sampleRegion),
1001 samplePatch_(samplePatch),
1003 offsetMode_(NORMAL),
1007 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1024 mode_(sampleModeNames_.get(
"sampleMode",
dict)),
1027 offsetMode_(UNIFORM),
1031 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1038 if (!coupleGroup_.valid())
1040 if (sampleRegion_.empty())
1043 sampleRegion_ = patch_.boundaryMesh().mesh().name();
1048 if (offsetModeNames_.readIfPresent(
"offsetMode",
dict, offsetMode_))
1050 switch (offsetMode_)
1061 offsets_ = readListOrField(
"offsets",
dict, patch_.size());
1074 offsetMode_ = UNIFORM;
1078 offsetMode_ = NONUNIFORM;
1080 offsets_ = readListOrField(
"offsets",
dict, patch_.size());
1082 else if (mode_ != NEARESTPATCHFACE && mode_ != NEARESTPATCHFACEAMI)
1085 <<
"Please supply the offsetMode as one of "
1104 offsetMode_(UNIFORM),
1108 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1115 if (
mode != NEARESTPATCHFACE &&
mode != NEARESTPATCHFACEAMI)
1118 <<
"Construct from sampleMode and dictionary only applicable for "
1119 <<
" collocated patches in modes "
1120 << sampleModeNames_[NEARESTPATCHFACE] <<
','
1121 << sampleModeNames_[NEARESTPATCHFACEAMI]
1126 if (!coupleGroup_.valid())
1128 if (sampleRegion_.empty())
1131 sampleRegion_ = patch_.boundaryMesh().mesh().name();
1178 offsetMode_ == NONUNIFORM
1225 const polyMesh& nbrMesh = sampleMesh();
1232 <<
"Cannot find patch " << samplePatch()
1233 <<
" in region " << sampleRegion_ <<
endl
1250 switch (offsetMode_)
1279 return samplePoints(facePoints(patch_));
1324 const point& basePoint =
p[
f[fp0]];
1326 label fp =
f.fcIndex(fp0);
1327 for (
label i = 2; i <
f.size(); i++)
1329 const point& thisPoint =
p[
f[fp]];
1330 label nextFp =
f.fcIndex(fp);
1331 const point& nextPoint =
p[
f[nextFp]];
1333 const triPointRef tri(basePoint, thisPoint, nextPoint);
1366 os.
writeEntry(
"sampleMode", sampleModeNames_[mode_]);
1367 if (!sampleRegion_.empty())
1369 os.
writeEntry(
"sampleRegion", sampleRegion_);
1371 if (!samplePatch_.empty())
1375 coupleGroup_.
write(os);
1379 offsetMode_ == UNIFORM
1381 && (mode_ == NEARESTPATCHFACE || mode_ == NEARESTPATCHFACEAMI)
1388 os.
writeEntry(
"offsetMode", offsetModeNames_[offsetMode_]);
1390 switch (offsetMode_)
1409 if (mode_ == NEARESTPATCHFACEAMI)
1416 if (!surfDict_.empty())
1418 surfDict_.
writeEntry(surfDict_.dictName(), os);
int debug
Static debugging option.
vectorField pointField
pointField is a vectorField.
virtual const pointField & points() const
Return raw points.
virtual void write(Ostream &) const
Write as a dictionary.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
#define InfoInFunction
Report an information message using Foam::Info.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
cellDecomposition
Enumeration defining the decomposition of the cell for.
const bool AMIReverse_
Flag to indicate that slave patch should be reversed for AMI.
const word & name() const
Return name.
const Field< PointType > & points() const
Return reference to global points.
bool hit() const
Is there a hit.
A class for handling words, derived from Foam::string.
A class for handling file names.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
A class for managing temporary objects.
static constexpr const zero Zero
Global zero.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
const mapDistribute & map() const
Return reference to the parallel distribution map.
Type gAverage(const FieldField< Field, Type > &f)
const Field< PointType > & localPoints() const
Return pointField of points in patch.
A List obtained as a section of another List.
const polyPatch & samplePolyPatch() const
Get the patch on the region.
Standard boundBox with extra functionality for use in octree.
const Time & time() const
Return time.
mappedPatchBase(const polyPatch &)
Construct from patch.
void collectSamples(const pointField &facePoints, pointField &, labelList &patchFaceProcs, labelList &patchFaces, pointField &patchFc) const
Collect single list of samples and originating processor+face.
vector offset_
Offset vector (uniform)
const sampleMode mode_
What to sample.
static const Enum< offsetMode > offsetModeNames_
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A token holds an item read from Istream.
static tmp< pointField > readListOrField(const word &keyword, const dictionary &dict, const label size)
Helper to read field or non-uniform list from dictionary.
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.
word samplePatch_
Patch (if in sampleMode NEARESTPATCH*)
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
nearest cell (even if not containing cell)
Mesh consisting of general polyhedral cells.
const coupleGroupIdentifier coupleGroup_
PatchGroup (if in sampleMode NEARESTPATCH*)
wordList names() const
Return a list of patch names.
const point & min() const
Minimum describing the bounding box.
virtual ~mappedPatchBase()
Destructor.
Holds (reference to) pointField. Encapsulation of data needed for octree searches....
static const Enum< sampleMode > sampleModeNames_
#define forAll(list, i)
Loop across all elements in list.
const autoPtr< Foam::searchableSurface > & surfPtr() const
Return a pointer to the AMI projection surface.
Field< vector > vectorField
Specialisation of Field<T> for vector.
MeshObject wrapper around meshSearch(mesh).
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
label facePoint(const int facei, const block &block, const label i, const label j)
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
autoPtr< mapDistribute > mapPtr_
Communication schedule:
word sampleRegion_
Region to sample.
tmp< pointField > samplePoints() const
Get the sample points.
A triangle primitive used to calculate face normals and swept volumes.
const polyMesh & sampleMesh() const
Get the region mesh.
label findNearestFace(const point &location, const label seedFacei=-1, const bool useTreeSearch=true) const
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
scalar distance() const
Return distance to hit.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Representation of a major/minor version number.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
An input stream of tokens.
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.
virtual const fileName & name() const
Return the name of the stream.
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
Class containing processor-to-processor mapping information.
virtual const labelList & faceOwner() const
Return face owner.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
scalarField samples(nIntervals, Zero)
const polyMesh & mesh() const
Return the mesh reference.
const Type & lookupObject(const word &name, const bool recursive=false) const
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
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;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
versionNumber version() const noexcept
Get the stream version.
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
vectorField offsets_
Offset vector (nonuniform)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool isWord() const
Token is WORD.
Macros for easy insertion into run-time selection tables.
scalar distance_
Offset distance (normal)
void calcAMI() const
Calculate AMI interpolator.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
errorManip< error > abort(error &err)
static autoPtr< searchableSurface > New(const word &surfaceType, const IOobject &io, const dictionary &dict)
Return a reference to the selected searchableSurface.
label start() const
Return start label of this patch in the polyMesh face list.
const word & sampleRegion() const
Region to sample.
const word & wordToken() const
Return const reference to the word contents.
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
scalar distance(const vector &p1, const vector &p2)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Output to file stream, using an OSstream.
static bool master(const label communicator=0)
Am I the master process.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
void calcMapping() const
Calculate mapping.
const vectorField & cellCentres() const
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
fileName path() const
Return path.
nearest face on selected patch
labelHashSet used(const bitSet &select)
Convert a bitset to a labelHashSet of the indices used.
Traits class for primitives.
Encapsulation of data needed to search for faces.
void putBack(const token &tok)
Put back token.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const vectorField & faceCentres() const
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
const dimensionedScalar e
Elementary charge.
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
offsetMode offsetMode_
How to obtain samples.
pointHit intersection(const point &p, const vector &q, const intersection::algorithm alg, const scalar tol=0.0) const
Fast intersection with a ray.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
nearest cell containing sample
const T2 & second() const noexcept
Return second.
offsetMode
How to project face centres.
const Time & time() const
Return the top-level database.
static const Vector< scalar > zero
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
A List with indirect addressing.
bool test(const Key &key) const
Same as found() - return true if key exists in the set.
void findSamples(const sampleMode mode, const pointField &, labelList &sampleProcs, labelList &sampleIndices, pointField &sampleLocations) const
Find cells/faces containing samples.
tmp< pointField > facePoints(const polyPatch &) const
Get the points from face-centre-decomposition face centres.
dictionary surfDict_
Dictionary storing projection surface description.
A face is a list of labels corresponding to mesh vertices.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
const polyPatch & patch_
Patch to sample.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
bool sameRegion_
Same region.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
vector point
Point is a vector.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
void setSize(const label newSize)
Alias for resize(const label)
const word & constant() const
Return constant name.
DynamicField< T, SizeMin > & append(const T &val)
Append an element at the end of the list.
static pointIndexHit facePoint(const polyMesh &, const label facei, const polyMesh::cellDecomposition)
Get a point on the face given a face decomposition method:
defineTypeNameAndDebug(combustionModel, 0)
const word & name() const
Return the patch name.
const T1 & first() const noexcept
Return first.
#define WarningInFunction
Report a warning using Foam::Warning.
const Point & hitPoint() const
Return hit point.
sampleMode
Mesh items to sample.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
bool set(const Key &key)
Same as insert (no value to overwrite)
A list of faces which address into the list of points.
UIndirectList< label > labelUIndList
UIndirectList of labels.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
const word & samplePatch() const
Patch (only if NEARESTPATCHFACE)