61 "nearestPatchFaceAMI",
134 patchFc = ListListOps::combine<pointField>
147 samples = ListListOps::combine<pointField>
161 patchFaces = ListListOps::combine<labelList>
179 for (
label i = 0; i < nPerProc[proci]; i++)
181 patchFaceProcs[sampleI++] = proci;
200 const polyMesh& mesh = sampleMesh();
209 if (samplePatch_.size() && samplePatch_ !=
"none")
212 <<
"No need to supply a patch name when in " 221 const point& sample = samples[sampleI];
227 nearest[sampleI].second().first() =
Foam::sqr(great);
240 nearest[sampleI].second().first() =
magSqr(cc-sample);
247 case NEARESTONLYCELL:
249 if (samplePatch_.size() && samplePatch_ !=
"none")
252 <<
"No need to supply a patch name when in " 261 const point& sample = samples[sampleI];
263 nearest[sampleI].
first() = tree.findNearest(sample,
sqr(great));
264 nearest[sampleI].second().first() =
magSqr 266 nearest[sampleI].first().hitPoint()
274 case NEARESTPATCHFACE:
282 nearest[sampleI].second().first() =
Foam::sqr(great);
312 const point& sample = samples[sampleI];
315 nearInfo = boundaryTree.findNearest
323 nearest[sampleI].second().first() =
Foam::sqr(great);
324 nearest[sampleI].second().second() =
331 nearest[sampleI].second().first() =
magSqr(fc-sample);
332 nearest[sampleI].second().second() =
340 case NEARESTPATCHPOINT:
348 nearest[sampleI].second().first() =
Foam::sqr(great);
375 const point& sample = samples[sampleI];
378 nearInfo = boundaryTree.findNearest
386 nearest[sampleI].second().first() =
Foam::sqr(great);
387 nearest[sampleI].second().second() =
394 nearest[sampleI].second().first() =
magSqr(pt-sample);
395 nearest[sampleI].second().second() =
405 if (samplePatch().size() && samplePatch() !=
"none")
408 <<
"No need to supply a patch name when in " 418 const point& sample = samples[sampleI];
424 nearest[sampleI].second().first() =
Foam::sqr(great);
437 nearest[sampleI].second().first() =
magSqr(fc-sample);
444 case NEARESTPATCHFACEAMI:
466 <<
"mesh " << sampleRegion() <<
" : " <<
endl;
470 label proci = nearest[sampleI].second().second();
471 label localI = nearest[sampleI].first().index();
473 Info<<
" " << sampleI <<
" coord:"<< samples[sampleI]
474 <<
" found on processor:" << proci
475 <<
" in local cell/face/point:" << localI
476 <<
" with location:" << nearest[sampleI].
first().rawPoint()
488 if (!nearest[sampleI].first().hit())
490 sampleProcs[sampleI] = -1;
491 sampleIndices[sampleI] = -1;
496 sampleProcs[sampleI] = nearest[sampleI].second().second();
497 sampleIndices[sampleI] = nearest[sampleI].
first().index();
498 sampleLocations[sampleI] = nearest[sampleI].
first().hitPoint();
506 static bool hasWarned =
false;
518 const pointField offsettedPoints(samplePoints(patchPoints()));
524 mode_ == NEARESTPATCHFACE
525 && sampleRegion() == patch_.boundaryMesh().mesh().name()
526 && samplePatch() == patch_.name()
531 bool coincident = (
gAverage(
mag(d)) <= rootVSmall);
533 if (sampleMyself && coincident)
536 <<
"Invalid offset " << d <<
endl 537 <<
"Offset is the vector added to the patch face centres to" 538 <<
" find the patch face supplying the data." <<
endl 539 <<
"Setting it to " << d
540 <<
" on the same patch, on the same region" 541 <<
" will find the faces themselves which does not make sense" 542 <<
" for anything but testing." <<
endl 543 <<
"patch_:" << patch_.
name() <<
endl 544 <<
"sampleRegion_:" << sampleRegion() <<
endl 545 <<
"mode_:" << sampleModeNames_[mode_] <<
endl 546 <<
"samplePatch_:" << samplePatch() <<
endl 547 <<
"offsetMode_:" << offsetModeNames_[offsetMode_] <<
endl;
568 findSamples(mode_, samples, sampleProcs, sampleIndices, sampleLocations);
572 if (mode_ == NEARESTCELL)
575 forAll(sampleProcs, sampleI)
577 if (sampleProcs[sampleI] == -1)
589 <<
"Did not find " << nNotFound
590 <<
" out of " << sampleProcs.
size() <<
" total samples." 591 <<
" Sampling these on owner cell centre instead." <<
endl 592 <<
"On patch " << patch_.
name()
593 <<
" on region " << sampleRegion()
594 <<
" in mode " << sampleModeNames_[mode_] <<
endl 595 <<
"with offset mode " << offsetModeNames_[offsetMode_]
596 <<
". Suppressing further warnings from " <<
type() <<
endl;
605 forAll(sampleProcs, sampleI)
607 if (sampleProcs[sampleI] == -1)
610 subSamples.
append(samples[sampleI]);
654 bool mapSucceeded =
true;
658 if (sampleProcs[i] == -1)
660 mapSucceeded =
false;
668 <<
"Mapping failed for " <<
nl 669 <<
" patch: " << patch_.name() <<
nl 670 <<
" sampleRegion: " << sampleRegion() <<
nl 671 <<
" mode: " << sampleModeNames_[mode_] <<
nl 672 <<
" samplePatch: " << samplePatch() <<
nl 673 <<
" offsetMode: " << offsetModeNames_[offsetMode_]
681 patch_.boundaryMesh().mesh().time().path()
685 Pout<<
"Dumping mapping as lines from patch faceCentres to" 686 <<
" sampled cell/faceCentres/points to file " << str.
name()
697 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
702 mapPtr_.reset(
new mapDistribute(sampleProcs, patchFaceProcs));
734 mapPtr_().constructSize() = patch_.
size();
740 forAll(constructMap, proci)
742 const labelList& map = constructMap[proci];
746 label facei = map[i];
748 if (used[facei] == 0)
755 <<
"On patch " << patch_.name()
756 <<
" patchface " << facei
757 <<
" is assigned to more than once." 764 if (used[facei] == 0)
767 <<
"On patch " << patch_.name()
768 <<
" patchface " << facei
769 <<
" is never assigned to." 780 const word surfType(surfDict_.lookupOrDefault<
word>(
"type",
"none"));
782 if (!surfPtr_.valid() && surfType !=
"none")
784 word surfName(surfDict_.lookupOrDefault(
"name", patch_.name()));
821 const polyPatch& nbr = samplePolyPatch();
825 OFstream os(patch_.name() +
"_neighbourPatch-org.obj");
839 OFstream osN(patch_.name() +
"_neighbourPatch-trans.obj");
842 OFstream osO(patch_.name() +
"_ownerPatch.obj");
882 token firstToken(is);
891 else if (firstToken.
wordToken() ==
"nonuniform")
894 if (fld.
size() != size)
899 ) <<
"size " << fld.
size()
900 <<
" is not equal to the given value of " << size
909 ) <<
"expected keyword 'uniform' or 'nonuniform', found " 921 ) <<
"expected keyword 'uniform' or 'nonuniform', " 922 "assuming List format for backwards compatibility." 923 "Foam version 2.0." <<
endl;
942 sampleRegion_(patch_.boundaryMesh().mesh().name()),
943 mode_(NEARESTPATCHFACE),
946 offsetMode_(UNIFORM),
948 offsets_(pp.size(), offset_),
950 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
962 const word& sampleRegion,
964 const word& samplePatch,
969 sampleRegion_(sampleRegion),
971 samplePatch_(samplePatch),
973 offsetMode_(NONUNIFORM),
977 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
989 const word& sampleRegion,
991 const word& samplePatch,
996 sampleRegion_(sampleRegion),
998 samplePatch_(samplePatch),
1000 offsetMode_(UNIFORM),
1004 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1016 const word& sampleRegion,
1018 const word& samplePatch,
1019 const scalar distance
1023 sampleRegion_(sampleRegion),
1025 samplePatch_(samplePatch),
1027 offsetMode_(NORMAL),
1030 distance_(distance),
1031 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1048 mode_(sampleModeNames_.read(dict.
lookup(
"sampleMode"))),
1051 offsetMode_(UNIFORM),
1055 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1062 if (!coupleGroup_.valid())
1064 if (sampleRegion_.empty())
1067 sampleRegion_ = patch_.boundaryMesh().mesh().name();
1072 if (dict.
found(
"offsetMode"))
1074 offsetMode_ = offsetModeNames_.read(dict.
lookup(
"offsetMode"));
1087 offsets_ = readListOrField(
"offsets", dict, patch_.size());
1093 distance_ = dict.
lookup<scalar>(
"distance");
1098 else if (dict.
found(
"offset"))
1100 offsetMode_ = UNIFORM;
1103 else if (dict.
found(
"offsets"))
1105 offsetMode_ = NONUNIFORM;
1107 offsets_ = readListOrField(
"offsets", dict, patch_.size());
1109 else if (mode_ != NEARESTPATCHFACE && mode_ != NEARESTPATCHFACEAMI)
1114 ) <<
"Please supply the offsetMode as one of " 1133 offsetMode_(UNIFORM),
1137 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1144 if (mode != NEARESTPATCHFACE && mode != NEARESTPATCHFACEAMI)
1149 ) <<
"Construct from sampleMode and dictionary only applicable for " 1150 <<
" collocated patches in modes " 1151 << sampleModeNames_[NEARESTPATCHFACE] <<
',' 1152 << sampleModeNames_[NEARESTPATCHFACEAMI]
1157 if (!coupleGroup_.valid())
1159 if (sampleRegion_.empty())
1162 sampleRegion_ = patch_.boundaryMesh().mesh().name();
1209 offsetMode_ == NONUNIFORM
1252 const polyMesh& nbrMesh = sampleMesh();
1259 <<
"Cannot find patch " << samplePatch()
1260 <<
" in region " << sampleRegion_ <<
endl 1277 switch (offsetMode_)
1306 return samplePoints(facePoints(patch_));
1351 const point& basePoint = p[f[fp0]];
1354 for (
label i = 2; i < f.size(); i++)
1356 const point& thisPoint = p[f[fp]];
1358 const point& nextPoint = p[f[nextFp]];
1360 const triPointRef tri(basePoint, thisPoint, nextPoint);
1393 writeEntry(os,
"sampleMode", sampleModeNames_[mode_]);
1394 if (!sampleRegion_.empty())
1396 writeEntry(os,
"sampleRegion", sampleRegion_);
1398 if (!samplePatch_.empty())
1402 coupleGroup_.write(os);
1406 offsetMode_ == UNIFORM
1408 && (mode_ == NEARESTPATCHFACE || mode_ == NEARESTPATCHFACEAMI)
1415 writeEntry(os,
"offsetMode", offsetModeNames_[offsetMode_]);
1417 switch (offsetMode_)
1436 if (mode_ == NEARESTPATCHFACEAMI)
1443 if (!surfDict_.empty())
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
word samplePatch_
Patch (if in sampleMode NEARESTPATCH*)
virtual const fileName & name() const
Return the name of the stream.
static wordList words()
The set of names as a list of words.
static void scatterList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Scatter data. Reverse of gatherList.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
#define forAll(list, i)
Loop across all elements in list.
mode_t mode(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file mode.
A triangle primitive used to calculate face areas and swept volumes.
vector offset_
Offset vector (uniform)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
Holds (reference to) pointField. Encapsulation of data needed for octree searches. Used for searching for nearest point. No bounding boxes around points. Only overlaps and calcNearest are implemented, rest makes little sense.
Ostream & writeKeyword(Foam::Ostream &os, const keyType &kw)
Write the keyword to the Ostream with the current level of indentation.
static const Vector< scalar > max
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
word sampleRegion_
Region to sample.
A list of keyword definitions, which are a keyword followed by any number of values (e...
MeshObject wrapper around meshSearch(mesh).
tmp< pointField > samplePoints() const
Get the sample points.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 2-tuple for storing two objects of different types.
const polyMesh & sampleMesh() const
Get the region mesh.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
Encapsulation of data needed to search for faces.
bool sameRegion_
Same region.
const Type1 & first() const
Return first.
T & ref() const
Return non-const reference or generate a fatal error.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
virtual void write(Ostream &) const
Write as a dictionary.
const word & wordToken() const
const coupleGroupIdentifier coupleGroup_
PatchGroup (if in sampleMode NEARESTPATCH*)
label findNearestFace(const point &location, const label seedFacei=-1, const bool useTreeSearch=true) const
virtual ~mappedPatchBase()
Destructor.
void size(const label)
Override size to be inconsistent with allocated storage.
A token holds items read from Istream.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
void putBack(const token &)
Put back token.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Traits class for primitives.
static bool master(const label communicator=0)
Am I the master process.
label findPatchID(const word &patchName) const
Find patch index given a name.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
PointIndexHit< point > pointIndexHit
versionNumber version() const
Return the stream version.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
T & first()
Return the first element of the list.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
Initialise the NamedEnum HashTable from the static list of names.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
cellDecomposition
Enumeration defining the decomposition of the cell for.
vectorField offsets_
Offset vector (nonuniform)
void setPoint(const Point &p)
Macros for easy insertion into run-time selection tables.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
scalar distance_
Offset distance (normal)
void collectSamples(const pointField &facePoints, pointField &, labelList &patchFaceProcs, labelList &patchFaces, pointField &patchFc) const
Collect single list of samples and originating processor+face.
virtual const pointField & points() const
Return raw points.
scalarField samples(nIntervals, 0)
A list of faces which address into the list of points.
const Point & hitPoint() const
Return hit point.
A List obtained as a section of another List.
vectorField pointField
pointField is a vectorField.
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))
static const word & geometryDir()
Return the geometry directory name.
A class for handling words, derived from string.
label size() const
Return the number of elements in the list.
virtual const fileName & name() const
Return the name of the stream.
const Point & hitPoint() const
Return hit point.
wordList names() const
Return a list of patch names.
const word & constant() const
Return constant name.
virtual const labelList & faceOwner() const
Return face owner.
static tmp< pointField > readListOrField(const word &keyword, const dictionary &dict, const label size)
Helper to read field or non-uniform list from dictionary.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
bool hit() const
Is there a hit.
const Field< PointType > & points() const
Return reference to global points.
void calcMapping() const
Calculate mapping.
const polyMesh & mesh() const
Return the mesh reference.
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
bool hit() const
Is there a hit.
offsetMode offsetMode_
How to obtain samples.
virtual const faceList & faces() const
Return raw faces.
const vectorField & cellCentres() const
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
tmp< pointField > facePoints(const polyPatch &) const
Get the points from face-centre-decomposition face centres.
const autoPtr< Foam::searchableSurface > & surfPtr() const
Return a pointer to the AMI projection surface.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
label facePoint(const int facei, const block &block, const label i, const label j)
const Time & time() const
Return time.
defineTypeNameAndDebug(combustionModel, 0)
static pointIndexHit facePoint(const polyMesh &, const label facei, const polyMesh::cellDecomposition)
Get a point on the face given a face decomposition method:
static meshSearchMeshObject & New(polyMesh &mesh)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
offsetMode
How to project face centres.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
static const NamedEnum< sampleMode, 6 > sampleModeNames_
void findSamples(const sampleMode mode, const pointField &, labelList &sampleProcs, labelList &sampleIndices, pointField &sampleLocations) const
Find cells/faces containing samples.
dictionary surfDict_
Dictionary storing projection surface description.
const vectorField & faceCentres() const
void setSize(const label)
Reset size of List.
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Class containing processor-to-processor mapping information.
void calcAMI() const
Calculate AMI interpolator.
vector point
Point is a vector.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
#define WarningInFunction
Report a warning using Foam::Warning.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Type gAverage(const FieldField< Field, Type > &f)
prefixOSstream Pout(cout, "Pout")
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
A List with indirect addressing.
sampleMode
Mesh items to sample.
label start() const
Return start label of this patch in the polyMesh face list.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
static autoPtr< searchableSurface > New(const word &surfaceType, const IOobject &io, const dictionary &dict)
Return a reference to the selected searchableSurface.
const bool AMIReverse_
Flag to indicate that slave patch should be reversed for AMI.
Standard boundBox + extra functionality for use in octree.
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
const doubleScalar e
Elementary charge.
Mesh consisting of general polyhedral cells.
scalar distance() const
Return distance to hit.
static const NamedEnum< offsetMode, 3 > offsetModeNames_
A class for managing temporary objects.
pointHit intersection(const point &p, const vector &q, const intersection::algorithm alg, const scalar tol=0.0) const
Fast intersection with a ray.
A patch is a list of labels that address the faces in the global face list.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
const polyPatch & samplePolyPatch() const
Get the patch on the region.
label index() const
Return index.
mappedPatchBase(const polyPatch &)
Construct from patch.
static const Vector< scalar > zero
DynamicField< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
dictionary subOrEmptyDict(const word &, const bool mustRead=false) const
Find and return a sub-dictionary as a copy, or.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
const sampleMode mode_
What to sample.
#define InfoInFunction
Report an information message using Foam::Info.