Go to the documentation of this file.
64 { sampleMode::NEARESTCELL,
"nearestCell" },
65 { sampleMode::NEARESTPATCHFACE,
"nearestPatchFace" },
66 { sampleMode::NEARESTPATCHFACEAMI,
"nearestPatchFaceAMI" },
67 { sampleMode::NEARESTPATCHPOINT,
"nearestPatchPoint" },
68 { sampleMode::NEARESTFACE,
"nearestFace" },
69 { sampleMode::NEARESTONLYCELL,
"nearestOnlyCell" },
79 { offsetMode::UNIFORM,
"uniform" },
80 { offsetMode::NONUNIFORM,
"nonuniform" },
81 { offsetMode::NORMAL,
"normal" },
95 (void)
mesh.tetBasePtIs();
107 polyMesh::FACE_DIAG_TRIS
127 globalFc[Pstream::myProcNo()] = facePoints;
128 Pstream::gatherList(globalFc);
129 Pstream::scatterList(globalFc);
131 patchFc = ListListOps::combine<pointField>
140 globalSamples[Pstream::myProcNo()] = samplePoints(facePoints);
141 Pstream::gatherList(globalSamples);
142 Pstream::scatterList(globalSamples);
144 samples = ListListOps::combine<pointField>
153 globalFaces[Pstream::myProcNo()] =
identity(patch_.size());
155 Pstream::gatherList(globalFaces);
156 Pstream::scatterList(globalFaces);
158 patchFaces = ListListOps::combine<labelList>
167 nPerProc[Pstream::myProcNo()] = patch_.size();
168 Pstream::gatherList(nPerProc);
169 Pstream::scatterList(nPerProc);
171 patchFaceProcs.
setSize(patchFaces.size());
176 for (label i = 0; i < nPerProc[proci]; i++)
178 patchFaceProcs[sampleI++] = proci;
206 if (samplePatch_.size() && samplePatch_ !=
"none")
209 <<
"No need to supply a patch name when in "
224 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
225 nearest[sampleI].second().second() = Pstream::myProcNo();
229 const point& cc =
mesh.cellCentres()[celli];
237 nearest[sampleI].second().first() =
magSqr(cc-sample);
238 nearest[sampleI].second().second() = Pstream::myProcNo();
244 case NEARESTONLYCELL:
246 if (samplePatch_.size() && samplePatch_ !=
"none")
249 <<
"No need to supply a patch name when in "
260 nearest[sampleI].first() = tree.findNearest(sample,
sqr(GREAT));
261 nearest[sampleI].second().first() =
magSqr
263 nearest[sampleI].first().hitPoint()
266 nearest[sampleI].second().second() = Pstream::myProcNo();
271 case NEARESTPATCHFACE:
281 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
282 nearest[sampleI].second().second() = Pstream::myProcNo();
298 patchBb.
min() -= point::uniform(ROOTVSMALL);
299 patchBb.max() += point::uniform(ROOTVSMALL);
328 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
329 nearest[sampleI].second().second() =
337 nearest[sampleI].second().second() =
345 case NEARESTPATCHPOINT:
355 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
356 nearest[sampleI].second().second() = Pstream::myProcNo();
370 patchBb.
min() -= point::uniform(ROOTVSMALL);
371 patchBb.max() += point::uniform(ROOTVSMALL);
399 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
400 nearest[sampleI].second().second() =
408 nearest[sampleI].second().second() =
418 if (samplePatch().size() && samplePatch() !=
"none")
421 <<
"No need to supply a patch name when in "
437 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
438 nearest[sampleI].second().second() = Pstream::myProcNo();
442 const point& fc =
mesh.faceCentres()[facei];
450 nearest[sampleI].second().first() =
magSqr(fc-sample);
451 nearest[sampleI].second().second() = Pstream::myProcNo();
457 case NEARESTPATCHFACEAMI:
472 Pstream::listCombineGather(nearest,
nearestEqOp());
473 Pstream::listCombineScatter(nearest);
479 <<
"mesh " << sampleRegion() <<
" : " <<
endl;
483 label proci = nearest[sampleI].second().second();
484 label localI = nearest[sampleI].first().index();
486 Info<<
" " << sampleI <<
" coord:"<<
samples[sampleI]
487 <<
" found on processor:" << proci
488 <<
" in local cell/face/point:" << localI
489 <<
" with location:" << nearest[sampleI].first().rawPoint()
497 sampleLocations.setSize(
samples.size());
501 if (!nearest[sampleI].first().hit())
503 sampleProcs[sampleI] = -1;
504 sampleIndices[sampleI] = -1;
509 sampleProcs[sampleI] = nearest[sampleI].second().second();
510 sampleIndices[sampleI] = nearest[sampleI].first().index();
511 sampleLocations[sampleI] = nearest[sampleI].first().hitPoint();
519 static bool hasWarned =
false;
544 bool coincident = (
gAverage(
mag(d)) <= ROOTVSMALL);
546 if (sampleMyself && coincident)
549 <<
"Invalid offset " << d <<
endl
550 <<
"Offset is the vector added to the patch face centres to"
551 <<
" find the patch face supplying the data." <<
endl
552 <<
"Setting it to " << d
553 <<
" on the same patch, on the same region"
554 <<
" will find the faces themselves which does not make sense"
555 <<
" for anything but testing." <<
endl
588 forAll(sampleProcs, sampleI)
590 if (sampleProcs[sampleI] == -1)
602 <<
"Did not find " << nNotFound
603 <<
" out of " << sampleProcs.size() <<
" total samples."
604 <<
" Sampling these on owner cell centre instead." <<
endl
609 <<
". Suppressing further warnings from " <<
type() <<
endl;
618 forAll(sampleProcs, sampleI)
620 if (sampleProcs[sampleI] == -1)
677 Pout<<
"Dumping mapping as lines from patch faceCentres to"
678 <<
" sampled cell/faceCentres/points to file " << str.
name()
689 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
705 constructMap[proci] =
labelUIndList(patchFaces, constructMap[proci]);
724 forAll(constructMap, proci)
730 label facei =
map[i];
736 <<
" patchface " << facei
737 <<
" is assigned to more than once."
752 <<
" patchface " << facei
753 <<
" is never assigned to."
764 const word surfType(surfDict_.getOrDefault<
word>(
"type",
"none"));
766 if (!surfPtr_.valid() && surfType !=
"none")
768 word surfName(surfDict_.getOrDefault(
"name", patch_.name()));
795 if (AMIPtr_->upToDate())
798 <<
"AMI already up-to-date"
804 const polyPatch& nbr = samplePolyPatch();
822 OFstream os(patch_.name() +
"_neighbourPatch-org.obj");
825 OFstream osN(patch_.name() +
"_neighbourPatch-trans.obj");
828 OFstream osO(patch_.name() +
"_ownerPatch.obj");
833 AMIPtr_->calculate(patch_, nbrPatch0, surfPtr());
843 mode_(NEARESTPATCHFACE),
846 offsetMode_(UNIFORM),
848 offsets_(pp.size(), offset_),
862 const word& sampleRegion,
864 const word& samplePatch,
869 sampleRegion_(sampleRegion),
871 samplePatch_(samplePatch),
873 offsetMode_(NONUNIFORM),
877 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
889 const word& sampleRegion,
891 const word& samplePatch,
896 sampleRegion_(sampleRegion),
898 samplePatch_(samplePatch),
900 offsetMode_(UNIFORM),
904 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
916 const word& sampleRegion,
918 const word& samplePatch,
923 sampleRegion_(sampleRegion),
925 samplePatch_(samplePatch),
931 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
948 mode_(sampleModeNames_.get(
"sampleMode",
dict)),
951 offsetMode_(UNIFORM),
955 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
970 if (!coupleGroup_.valid())
972 if (sampleRegion_.empty())
975 sampleRegion_ = patch_.boundaryMesh().mesh().name();
980 if (offsetModeNames_.readIfPresent(
"offsetMode",
dict, offsetMode_))
1005 offsetMode_ = UNIFORM;
1009 offsetMode_ = NONUNIFORM;
1012 else if (mode_ != NEARESTPATCHFACE && mode_ != NEARESTPATCHFACEAMI)
1015 <<
"Please supply the offsetMode as one of "
1034 offsetMode_(UNIFORM),
1038 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1053 if (
mode != NEARESTPATCHFACE &&
mode != NEARESTPATCHFACEAMI)
1056 <<
"Construct from sampleMode and dictionary only applicable for "
1057 <<
" collocated patches in modes "
1058 << sampleModeNames_[NEARESTPATCHFACE] <<
','
1059 << sampleModeNames_[NEARESTPATCHFACEAMI]
1064 if (!coupleGroup_.valid())
1066 if (sampleRegion_.empty())
1069 sampleRegion_ = patch_.boundaryMesh().mesh().name();
1094 AMIPtr_(mpb.
AMIPtr_->clone()),
1116 offsetMode_ == NONUNIFORM
1124 AMIPtr_(mpb.
AMIPtr_->clone()),
1142 AMIPtr_->upToDate() =
false;
1163 const polyMesh& nbrMesh = sampleMesh();
1170 <<
"Cannot find patch " << samplePatch()
1171 <<
" in region " << sampleRegion_ <<
endl
1188 switch (offsetMode_)
1217 return samplePoints(facePoints(patch_));
1262 const point& basePoint =
p[
f[fp0]];
1264 label fp =
f.fcIndex(fp0);
1265 for (label i = 2; i <
f.size(); i++)
1267 const point& thisPoint =
p[
f[fp]];
1268 label nextFp =
f.fcIndex(fp);
1269 const point& nextPoint =
p[
f[nextFp]];
1271 const triPointRef tri(basePoint, thisPoint, nextPoint);
1304 os.
writeEntry(
"sampleMode", sampleModeNames_[mode_]);
1305 if (!sampleRegion_.empty())
1307 os.
writeEntry(
"sampleRegion", sampleRegion_);
1309 if (!samplePatch_.empty())
1313 coupleGroup_.
write(os);
1317 offsetMode_ == UNIFORM
1319 && (mode_ == NEARESTPATCHFACE || mode_ == NEARESTPATCHFACEAMI)
1326 os.
writeEntry(
"offsetMode", offsetModeNames_[offsetMode_]);
1328 switch (offsetMode_)
1347 if (mode_ == NEARESTPATCHFACEAMI)
1354 if (!surfDict_.empty())
1356 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.
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 (0)
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)
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.
bool test(const Key &key) const noexcept
Same as found() - return true if key exists in the set.
static const Enum< offsetMode > offsetModeNames_
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
word samplePatch_
Patch (if in sampleMode NEARESTPATCH*)
static autoPtr< AMIInterpolation > New(const word &modelName, const dictionary &dict, const bool reverseTarget=false)
Selector for dictionary.
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.
Face area weighted Arbitrary Mesh Interface (AMI) method.
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.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
messageStream Info
Information stream (uses stdout - output is on the master only)
#define DebugInFunction
Report an information message using Foam::Info.
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.
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.
vectorField offsets_
Offset vector (nonuniform)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const Field< point_type > & points() const
Return reference to global points.
Macros for easy insertion into run-time selection tables.
scalar distance_
Offset distance (normal)
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
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.
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)
const Field< point_type > & localPoints() const
Return pointField of points in patch.
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.
Encapsulation of data needed to search for faces.
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.
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
A List with indirect addressing.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
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.
autoPtr< AMIPatchToPatchInterpolation > AMIPtr_
Pointer to AMI interpolator.
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.
bool sameRegion_
Same region.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
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.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
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
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)