Go to the documentation of this file.
61 "nearestPatchFaceAMI",
98 (void)
mesh.tetBasePtIs();
110 polyMesh::FACE_DIAG_TRIS
130 globalFc[Pstream::myProcNo()] = facePoints;
131 Pstream::gatherList(globalFc);
132 Pstream::scatterList(globalFc);
134 patchFc = ListListOps::combine<pointField>
143 globalSamples[Pstream::myProcNo()] = samplePoints(facePoints);
144 Pstream::gatherList(globalSamples);
145 Pstream::scatterList(globalSamples);
147 samples = ListListOps::combine<pointField>
156 globalFaces[Pstream::myProcNo()] =
identity(patch_.size());
158 Pstream::gatherList(globalFaces);
159 Pstream::scatterList(globalFaces);
170 nPerProc[Pstream::myProcNo()] = patch_.
size();
171 Pstream::gatherList(nPerProc);
172 Pstream::scatterList(nPerProc);
179 for (
label i = 0; i < nPerProc[procI]; i++)
181 patchFaceProcs[sampleI++] = procI;
209 if (samplePatch_.size() && samplePatch_ !=
"none")
212 <<
"No need to supply a patch name when in "
227 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
228 nearest[sampleI].second().second() = Pstream::myProcNo();
232 const point& cc =
mesh.cellCentres()[cellI];
240 nearest[sampleI].second().first() =
magSqr(cc-sample);
241 nearest[sampleI].second().second() = Pstream::myProcNo();
247 case NEARESTONLYCELL:
249 if (samplePatch_.size() && samplePatch_ !=
"none")
252 <<
"No need to supply a patch name when in "
264 nearest[sampleI].second().first() =
magSqr
266 nearest[sampleI].first().hitPoint()
269 nearest[sampleI].second().second() = Pstream::myProcNo();
274 case NEARESTPATCHFACE:
284 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
285 nearest[sampleI].second().second() = Pstream::myProcNo();
301 patchBb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
302 patchBb.
max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
331 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
332 nearest[sampleI].second().second() =
339 nearest[sampleI].second().first() =
magSqr(fc-sample);
340 nearest[sampleI].second().second() =
348 case NEARESTPATCHPOINT:
358 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
359 nearest[sampleI].second().second() = Pstream::myProcNo();
373 patchBb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
374 patchBb.
max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
402 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
403 nearest[sampleI].second().second() =
410 nearest[sampleI].second().first() =
magSqr(pt-sample);
411 nearest[sampleI].second().second() =
421 if (samplePatch().size() && samplePatch() !=
"none")
424 <<
"No need to supply a patch name when in "
440 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
441 nearest[sampleI].second().second() = Pstream::myProcNo();
445 const point& fc =
mesh.faceCentres()[faceI];
453 nearest[sampleI].second().first() =
magSqr(fc-sample);
454 nearest[sampleI].second().second() = Pstream::myProcNo();
460 case NEARESTPATCHFACEAMI:
475 Pstream::listCombineGather(nearest,
nearestEqOp());
476 Pstream::listCombineScatter(nearest);
481 Info<<
"mappedPatchBase::findSamples on mesh " << sampleRegion()
485 label procI = nearest[sampleI].second().second();
486 label localI = nearest[sampleI].first().index();
488 Info<<
" " << sampleI <<
" coord:"<<
samples[sampleI]
489 <<
" found on processor:" << procI
490 <<
" in local cell/face/point:" << localI
491 <<
" with location:" << nearest[sampleI].first().rawPoint()
499 sampleLocations.setSize(
samples.size());
503 if (!nearest[sampleI].first().hit())
505 sampleProcs[sampleI] = -1;
506 sampleIndices[sampleI] = -1;
511 sampleProcs[sampleI] = nearest[sampleI].second().second();
512 sampleIndices[sampleI] = nearest[sampleI].first().index();
513 sampleLocations[sampleI] = nearest[sampleI].first().hitPoint();
521 static bool hasWarned =
false;
546 bool coincident = (
gAverage(
mag(d)) <= ROOTVSMALL);
548 if (sampleMyself && coincident)
551 <<
"Invalid offset " << d <<
endl
552 <<
"Offset is the vector added to the patch face centres to"
553 <<
" find the patch face supplying the data." <<
endl
554 <<
"Setting it to " << d
555 <<
" on the same patch, on the same region"
556 <<
" will find the faces themselves which does not make sense"
557 <<
" for anything but testing." <<
endl
590 forAll(sampleProcs, sampleI)
592 if (sampleProcs[sampleI] == -1)
604 <<
"Did not find " << nNotFound
605 <<
" out of " << sampleProcs.
size() <<
" total samples."
606 <<
" Sampling these on owner cell centre instead." <<
endl
611 <<
". Suppressing further warnings from " <<
type() <<
endl;
620 forAll(sampleProcs, sampleI)
622 if (sampleProcs[sampleI] == -1)
679 Pout<<
"Dumping mapping as lines from patch faceCentres to"
680 <<
" sampled cell/faceCentres/points to file " << str.
name()
691 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
734 forAll(constructMap, procI)
742 if (used[faceI] == 0)
750 <<
" patchface " << faceI
751 <<
" is assigned to more than once."
758 if (used[faceI] == 0)
762 <<
" patchface " << faceI
763 <<
" is never assigned to."
774 const word surfType(surfDict_.lookupOrDefault<
word>(
"type",
"none"));
776 if (!surfPtr_.valid() && surfType !=
"none")
778 word surfName(surfDict_.lookupOrDefault(
"name", patch_.name()));
814 const polyPatch& nbr = samplePolyPatch();
832 OFstream os(patch_.name() +
"_neighbourPatch-org.obj");
835 OFstream osN(patch_.name() +
"_neighbourPatch-trans.obj");
838 OFstream osO(patch_.name() +
"_ownerPatch.obj");
878 token firstToken(is);
887 else if (firstToken.
wordToken() ==
"nonuniform")
890 if (
fld.size() != size)
895 ) <<
"size " <<
fld.size()
896 <<
" is not equal to the given value of " << size
905 ) <<
"expected keyword 'uniform' or 'nonuniform', found "
917 ) <<
"expected keyword 'uniform' or 'nonuniform', "
918 "assuming List format for backwards compatibility."
919 "Foam version 2.0." <<
endl;
938 sampleRegion_(patch_.boundaryMesh().mesh().name()),
939 mode_(NEARESTPATCHFACE),
942 offsetMode_(UNIFORM),
944 offsets_(pp.size(), offset_),
946 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
958 const word& sampleRegion,
960 const word& samplePatch,
965 sampleRegion_(sampleRegion),
967 samplePatch_(samplePatch),
969 offsetMode_(NONUNIFORM),
973 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
985 const word& sampleRegion,
987 const word& samplePatch,
992 sampleRegion_(sampleRegion),
994 samplePatch_(samplePatch),
996 offsetMode_(UNIFORM),
1000 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1012 const word& sampleRegion,
1014 const word& samplePatch,
1019 sampleRegion_(sampleRegion),
1021 samplePatch_(samplePatch),
1023 offsetMode_(NORMAL),
1027 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1044 mode_(sampleModeNames_.read(
dict.
lookup(
"sampleMode"))),
1047 offsetMode_(UNIFORM),
1051 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1058 if (!coupleGroup_.valid())
1060 if (sampleRegion_.empty())
1063 sampleRegion_ = patch_.boundaryMesh().mesh().name();
1070 offsetMode_ = offsetModeNames_.read(
dict.
lookup(
"offsetMode"));
1083 offsets_ = readListOrField(
"offsets",
dict, patch_.size());
1096 offsetMode_ = UNIFORM;
1101 offsetMode_ = NONUNIFORM;
1103 offsets_ = readListOrField(
"offsets",
dict, patch_.size());
1105 else if (mode_ != NEARESTPATCHFACE && mode_ != NEARESTPATCHFACEAMI)
1110 ) <<
"Please supply the offsetMode as one of "
1129 offsetMode_(UNIFORM),
1133 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1140 if (
mode != NEARESTPATCHFACE &&
mode != NEARESTPATCHFACEAMI)
1145 ) <<
"Construct from sampleMode and dictionary only applicable for "
1146 <<
" collocated patches in modes "
1147 << sampleModeNames_[NEARESTPATCHFACE] <<
','
1148 << sampleModeNames_[NEARESTPATCHFACEAMI]
1153 if (!coupleGroup_.valid())
1155 if (sampleRegion_.empty())
1158 sampleRegion_ = patch_.boundaryMesh().mesh().name();
1205 offsetMode_ == NONUNIFORM
1248 const polyMesh& nbrMesh = sampleMesh();
1255 <<
"Cannot find patch " << samplePatch()
1256 <<
" in region " << sampleRegion_ <<
endl
1273 switch (offsetMode_)
1302 return samplePoints(facePoints(patch_));
1347 const point& basePoint =
p[
f[fp0]];
1349 label fp =
f.fcIndex(fp0);
1352 const point& thisPoint =
p[
f[fp]];
1353 label nextFp =
f.fcIndex(fp);
1354 const point& nextPoint =
p[
f[nextFp]];
1356 const triPointRef tri(basePoint, thisPoint, nextPoint);
1389 os.
writeKeyword(
"sampleMode") << sampleModeNames_[mode_]
1391 if (!sampleRegion_.empty())
1396 if (!samplePatch_.empty())
1401 coupleGroup_.write(os);
1405 offsetMode_ == UNIFORM
1407 && (mode_ == NEARESTPATCHFACE || mode_ == NEARESTPATCHFACEAMI)
1414 os.
writeKeyword(
"offsetMode") << offsetModeNames_[offsetMode_]
1417 switch (offsetMode_)
1427 offsets_.writeEntry(
"offsets", os);
1438 if (mode_ == NEARESTPATCHFACEAMI)
1446 if (!surfDict_.empty())
vectorField pointField
pointField is a vectorField.
Simple random number generator.
virtual const pointField & points() const
Return raw points.
virtual void write(Ostream &) const
Write as a dictionary.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
cellDecomposition
Enumeration defining the decomposition of the cell for.
label findPatchID(const word &patchName) const
Find patch index given a name.
const bool AMIReverse_
Flag to indicate that slave patch should be reversed for AMI.
const Field< PointType > & points() const
Return reference to global points.
bool hit() const
Is there a hit.
A class for handling words, derived from string.
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
A class for handling file names.
const point & max() const
Maximum describing the bounding box.
#define forAll(list, i)
Loop across all elements in list.
A class for managing temporary objects.
This class describes the interaction of a face and a point. It carries the info of a successful hit a...
const mapDistribute & map() const
Return reference to the parallel distribution map.
Type gAverage(const FieldField< Field, Type > &f)
const labelList & tetBasePtIs() const
Return the tetBasePtIs.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
A List obtained as a section of another List.
static wordList words()
The set of names as a list of words.
const polyPatch & samplePolyPatch() const
Get the patch on the region.
Standard boundBox + extra functionality for use in octree.
const Time & time() const
Return time.
const word & wordToken() const
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
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)
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
const sampleMode mode_
What to sample.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A token holds items 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.
word samplePatch_
Patch (if in sampleMode NEARESTPATCH*)
dimensioned< scalar > mag(const dimensioned< Type > &)
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
labelList patchFaces(const polyBoundaryMesh &patches, const wordList &names)
mode_t mode(const fileName &)
Return the file mode.
Mesh consisting of general polyhedral cells.
const coupleGroupIdentifier coupleGroup_
PatchGroup (if in sampleMode NEARESTPATCH*)
wordList names() const
Return a list of patch names.
virtual ~mappedPatchBase()
Destructor.
Holds (reference to) pointField. Encapsulation of data needed for octree searches....
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).
label facePoint(const int facei, const block &block, const label i, const label j)
autoPtr< mapDistribute > mapPtr_
Communication schedule:
vector span() const
The bounding box span (from minimum to maximum)
word sampleRegion_
Region to sample.
tmp< pointField > samplePoints() const
Get the sample points.
A triangle primitive used to calculate face normals and swept volumes.
scalarField samples(nIntervals, 0)
const polyMesh & sampleMesh() const
Get the region mesh.
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...
static const NamedEnum< sampleMode, 6 > sampleModeNames_
scalar distance() const
Return distance to hit.
label findNearestFace(const point &location, const label seedFaceI=-1, const bool useTreeSearch=true) const
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Pre-declare SubField and related Field type.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
treeBoundBox extend(Random &, const scalar s) const
Return slightly wider bounding box.
A patch is a list of labels that address the faces in the global face list.
Class containing processor-to-processor mapping information.
virtual const labelList & faceOwner() const
Return face owner.
DynamicField< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
const word & name() const
Return name.
const polyMesh & mesh() const
Return the mesh reference.
const point & min() const
Minimum describing the bounding box.
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
vectorField offsets_
Offset vector (nonuniform)
A list of keyword definitions, which are a keyword followed by any number of values (e....
Macros for easy insertion into run-time selection tables.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
scalar distance_
Offset distance (normal)
void calcAMI() const
Calculate AMI interpolator.
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.
scalar distance(const vector &p1, const vector &p2)
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static bool master(const label communicator=0)
Am I the master process.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
void calcMapping() const
Calculate mapping.
void setSize(const label)
Reset size of List.
const vectorField & cellCentres() const
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static const NamedEnum< offsetMode, 3 > offsetModeNames_
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
fileName path() const
Return path.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
prefixOSstream Pout(cout, "Pout")
versionNumber version() const
Return the stream version.
static pointIndexHit facePoint(const polyMesh &, const label faceI, const polyMesh::cellDecomposition)
Get a point on the face given a face decomposition method:
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Traits class for primitives.
void putBack(const token &)
Put back token.
Encapsulation of data needed to search for faces.
const vectorField & faceCentres() const
const word & constant() const
Return constant name.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
const dimensionedScalar e
Elementary charge.
dictionary subOrEmptyDict(const word &, const bool mustRead=false) const
Find and return a sub-dictionary as a copy, or.
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.
offsetMode
How to project face centres.
const Time & time() const
Return the top-level database.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
A List with indirect addressing.
void findNearest(const label nodeI, const linePointRef &ln, treeBoundBox &tightest, label &nearestShapeI, point &linePoint, point &nearestPoint, const FindNearestOp &fnOp) const
Find nearest point to line.
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.
const fileName & name() const
Return the name of the stream.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
void size(const label)
Override size to be inconsistent with allocated storage.
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 different types.
vector point
Point is a vector.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
defineTypeNameAndDebug(combustionModel, 0)
const word & name() const
Return name.
#define WarningInFunction
Report a warning using Foam::Warning.
const Point & hitPoint() const
Return hit point.
sampleMode
Mesh items to sample.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
cachedRandom rndGen(label(0), -1)
Initialise the NamedEnum HashTable from the static list of names.
A list of faces which address into the list of points.
const word & samplePatch() const
Patch (only if NEARESTPATCHFACE)