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:
284 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
301 patchBb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
302 patchBb.max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
320 const point& sample = samples[sampleI];
323 nearInfo = boundaryTree.findNearest
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);
373 patchBb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
374 patchBb.max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
391 const point& sample = samples[sampleI];
394 nearInfo = boundaryTree.findNearest
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 " 434 const point& sample = samples[sampleI];
440 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
453 nearest[sampleI].second().first() =
magSqr(fc-sample);
460 case NEARESTPATCHFACEAMI:
482 <<
"mesh " << sampleRegion() <<
" : " <<
endl;
486 label proci = nearest[sampleI].second().second();
487 label localI = nearest[sampleI].first().index();
489 Info<<
" " << sampleI <<
" coord:"<< samples[sampleI]
490 <<
" found on processor:" << proci
491 <<
" in local cell/face/point:" << localI
492 <<
" with location:" << nearest[sampleI].
first().rawPoint()
504 if (!nearest[sampleI].first().hit())
506 sampleProcs[sampleI] = -1;
507 sampleIndices[sampleI] = -1;
512 sampleProcs[sampleI] = nearest[sampleI].second().second();
513 sampleIndices[sampleI] = nearest[sampleI].
first().index();
514 sampleLocations[sampleI] = nearest[sampleI].
first().hitPoint();
522 static bool hasWarned =
false;
534 const pointField offsettedPoints(samplePoints(patchPoints()));
540 mode_ == NEARESTPATCHFACE
541 && sampleRegion() == patch_.boundaryMesh().mesh().name()
542 && samplePatch() == patch_.name()
547 bool coincident = (
gAverage(
mag(d)) <= ROOTVSMALL);
549 if (sampleMyself && coincident)
552 <<
"Invalid offset " << d <<
endl 553 <<
"Offset is the vector added to the patch face centres to" 554 <<
" find the patch face supplying the data." <<
endl 555 <<
"Setting it to " << d
556 <<
" on the same patch, on the same region" 557 <<
" will find the faces themselves which does not make sense" 558 <<
" for anything but testing." <<
endl 559 <<
"patch_:" << patch_.
name() <<
endl 560 <<
"sampleRegion_:" << sampleRegion() <<
endl 561 <<
"mode_:" << sampleModeNames_[mode_] <<
endl 562 <<
"samplePatch_:" << samplePatch() <<
endl 563 <<
"offsetMode_:" << offsetModeNames_[offsetMode_] <<
endl;
584 findSamples(mode_, samples, sampleProcs, sampleIndices, sampleLocations);
588 if (mode_ == NEARESTCELL)
591 forAll(sampleProcs, sampleI)
593 if (sampleProcs[sampleI] == -1)
605 <<
"Did not find " << nNotFound
606 <<
" out of " << sampleProcs.
size() <<
" total samples." 607 <<
" Sampling these on owner cell centre instead." <<
endl 608 <<
"On patch " << patch_.
name()
609 <<
" on region " << sampleRegion()
610 <<
" in mode " << sampleModeNames_[mode_] <<
endl 611 <<
"with offset mode " << offsetModeNames_[offsetMode_]
612 <<
". Suppressing further warnings from " <<
type() <<
endl;
621 forAll(sampleProcs, sampleI)
623 if (sampleProcs[sampleI] == -1)
626 subSamples.
append(samples[sampleI]);
676 patch_.boundaryMesh().mesh().time().path()
680 Pout<<
"Dumping mapping as lines from patch faceCentres to" 681 <<
" sampled cell/faceCentres/points to file " << str.
name()
692 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
697 mapPtr_.reset(
new mapDistribute(sampleProcs, patchFaceProcs));
729 mapPtr_().constructSize() = patch_.
size();
735 forAll(constructMap, proci)
737 const labelList& map = constructMap[proci];
741 label facei = map[i];
743 if (used[facei] == 0)
750 <<
"On patch " << patch_.name()
751 <<
" patchface " << facei
752 <<
" is assigned to more than once." 759 if (used[facei] == 0)
762 <<
"On patch " << patch_.name()
763 <<
" patchface " << facei
764 <<
" is never assigned to." 775 const word surfType(surfDict_.lookupOrDefault<
word>(
"type",
"none"));
777 if (!surfPtr_.valid() && surfType !=
"none")
779 word surfName(surfDict_.lookupOrDefault(
"name", patch_.name()));
816 const polyPatch& nbr = samplePolyPatch();
820 OFstream os(patch_.name() +
"_neighbourPatch-org.obj");
834 OFstream osN(patch_.name() +
"_neighbourPatch-trans.obj");
837 OFstream osO(patch_.name() +
"_ownerPatch.obj");
877 token firstToken(is);
886 else if (firstToken.
wordToken() ==
"nonuniform")
889 if (fld.
size() != size)
894 ) <<
"size " << fld.
size()
895 <<
" is not equal to the given value of " << size
904 ) <<
"expected keyword 'uniform' or 'nonuniform', found " 916 ) <<
"expected keyword 'uniform' or 'nonuniform', " 917 "assuming List format for backwards compatibility." 918 "Foam version 2.0." <<
endl;
937 sampleRegion_(patch_.boundaryMesh().mesh().name()),
938 mode_(NEARESTPATCHFACE),
941 offsetMode_(UNIFORM),
943 offsets_(pp.size(), offset_),
945 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
957 const word& sampleRegion,
959 const word& samplePatch,
964 sampleRegion_(sampleRegion),
966 samplePatch_(samplePatch),
968 offsetMode_(NONUNIFORM),
972 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
984 const word& sampleRegion,
986 const word& samplePatch,
991 sampleRegion_(sampleRegion),
993 samplePatch_(samplePatch),
995 offsetMode_(UNIFORM),
999 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1011 const word& sampleRegion,
1013 const word& samplePatch,
1014 const scalar distance
1018 sampleRegion_(sampleRegion),
1020 samplePatch_(samplePatch),
1022 offsetMode_(NORMAL),
1025 distance_(distance),
1026 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1043 mode_(sampleModeNames_.read(dict.
lookup(
"sampleMode"))),
1046 offsetMode_(UNIFORM),
1050 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1057 if (!coupleGroup_.valid())
1059 if (sampleRegion_.empty())
1062 sampleRegion_ = patch_.boundaryMesh().mesh().name();
1067 if (dict.
found(
"offsetMode"))
1069 offsetMode_ = offsetModeNames_.read(dict.
lookup(
"offsetMode"));
1082 offsets_ = readListOrField(
"offsets", dict, patch_.
size());
1093 else if (dict.
found(
"offset"))
1095 offsetMode_ = UNIFORM;
1098 else if (dict.
found(
"offsets"))
1100 offsetMode_ = NONUNIFORM;
1102 offsets_ = readListOrField(
"offsets", dict, patch_.
size());
1104 else if (mode_ != NEARESTPATCHFACE && mode_ != NEARESTPATCHFACEAMI)
1109 ) <<
"Please supply the offsetMode as one of " 1128 offsetMode_(UNIFORM),
1132 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1139 if (mode != NEARESTPATCHFACE && mode != NEARESTPATCHFACEAMI)
1144 ) <<
"Construct from sampleMode and dictionary only applicable for " 1145 <<
" collocated patches in modes " 1146 << sampleModeNames_[NEARESTPATCHFACE] <<
',' 1147 << sampleModeNames_[NEARESTPATCHFACEAMI]
1152 if (!coupleGroup_.valid())
1154 if (sampleRegion_.empty())
1157 sampleRegion_ = patch_.boundaryMesh().mesh().name();
1204 offsetMode_ == NONUNIFORM
1247 const polyMesh& nbrMesh = sampleMesh();
1254 <<
"Cannot find patch " << samplePatch()
1255 <<
" in region " << sampleRegion_ <<
endl 1272 switch (offsetMode_)
1301 return samplePoints(facePoints(patch_));
1346 const point& basePoint = p[f[fp0]];
1349 for (
label i = 2; i < f.size(); i++)
1351 const point& thisPoint = p[f[fp]];
1353 const point& nextPoint = p[f[nextFp]];
1355 const triPointRef tri(basePoint, thisPoint, nextPoint);
1388 os.
writeKeyword(
"sampleMode") << sampleModeNames_[mode_]
1390 if (!sampleRegion_.empty())
1395 if (!samplePatch_.empty())
1400 coupleGroup_.write(os);
1404 offsetMode_ == UNIFORM
1406 && (mode_ == NEARESTPATCHFACE || mode_ == NEARESTPATCHFACEAMI)
1413 os.
writeKeyword(
"offsetMode") << offsetModeNames_[offsetMode_]
1416 switch (offsetMode_)
1426 offsets_.writeEntry(
"offsets", os);
1437 if (mode_ == NEARESTPATCHFACEAMI)
1445 if (!surfDict_.empty())
virtual void write(Ostream &) const
Write as a dictionary.
cachedRandom rndGen(label(0),-1)
const Time & time() const
Return time.
word samplePatch_
Patch (if in sampleMode NEARESTPATCH*)
static const Vector< scalar > max
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.
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.
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
A triangle primitive used to calculate face normals 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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
wordList names() const
Return a list of patch names.
const Type1 & first() const
Return first.
A face is a list of labels corresponding to mesh vertices.
word sampleRegion_
Region to sample.
const double e
Elementary charge.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
const point & min() const
Minimum describing the bounding box.
A list of keyword definitions, which are a keyword followed by any number of values (e...
MeshObject wrapper around meshSearch(mesh).
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 2-tuple for storing two objects of different types.
Encapsulation of data needed to search for faces.
bool sameRegion_
Same region.
dictionary subOrEmptyDict(const word &, const bool mustRead=false) const
Find and return a sub-dictionary as a copy, or.
bool hit() const
Is there a hit.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
const coupleGroupIdentifier coupleGroup_
PatchGroup (if in sampleMode NEARESTPATCH*)
virtual ~mappedPatchBase()
Destructor.
void size(const label)
Override size to be inconsistent with allocated storage.
A token holds items read from Istream.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
label findNearestFace(const point &location, const label seedFacei=-1, const bool useTreeSearch=true) const
void putBack(const token &)
Put back token.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Traits class for primitives.
const Field< PointType > & points() const
Return reference to global points.
static bool master(const label communicator=0)
Am I the master process.
const polyMesh & sampleMesh() const
Get the region mesh.
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
const vectorField & faceCentres() const
const autoPtr< Foam::searchableSurface > & surfPtr() const
Return a pointer to the AMI projection surface.
label size() const
Return number of elements in list.
T & first()
Return the first element of the list.
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.
void calcAMI() const
Calculate AMI interpolator.
vectorField offsets_
Offset vector (nonuniform)
void setPoint(const Point &p)
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Macros for easy insertion into run-time selection tables.
scalar distance_
Offset distance (normal)
virtual const pointField & points() const
Return raw points.
tmp< pointField > facePoints(const polyPatch &) const
Get the points from face-centre-decomposition face centres.
static const meshSearchMeshObject & New(const polyMesh &mesh)
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
scalarField samples(nIntervals, 0)
A list of faces which address into the list of points.
A List obtained as a section of another List.
scalar distance() const
Return distance to hit.
void findSamples(const sampleMode mode, const pointField &, labelList &sampleProcs, labelList &sampleIndices, pointField &sampleLocations) const
Find cells/faces containing samples.
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))
label start() const
Return start label of this patch in the polyMesh face list.
void calcMapping() const
Calculate mapping.
tmp< pointField > samplePoints() const
Get the sample points.
A class for handling words, derived from string.
virtual const fileName & name() const
Return the name of the stream.
label size() const
Return the number of elements in the list.
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.
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
const word & constant() const
Return constant name.
const vectorField & cellCentres() const
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
offsetMode offsetMode_
How to obtain samples.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
versionNumber version() const
Return the stream version.
errorManip< error > abort(error &err)
const polyMesh & mesh() const
Return the mesh reference.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Simple random number generator.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
prefixOSstream Pout(cout,"Pout")
virtual const fileName & name() const
Return the name of the stream.
label facePoint(const int facei, const block &block, const label i, const label j)
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:
const labelList & tetBasePtIs() const
Return the tetBasePtIs.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
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_
dictionary surfDict_
Dictionary storing projection surface description.
void setSize(const label)
Reset size of List.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Class containing processor-to-processor mapping information.
const polyPatch & samplePolyPatch() const
Get the patch on the region.
vector point
Point is a vector.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
#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)
const Point & hitPoint() const
Return hit point.
mode_t mode(const fileName &)
Return the file mode.
label index() const
Return index.
A List with indirect addressing.
sampleMode
Mesh items to sample.
const word & wordToken() const
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
const Point & hitPoint() const
Return hit point.
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.
bool hit() const
Is there a hit.
Mesh consisting of general polyhedral cells.
static const Vector< scalar > zero
static const NamedEnum< offsetMode, 3 > offsetModeNames_
pointHit intersection(const point &p, const vector &q, const intersection::algorithm alg, const scalar tol=0.0) const
Fast intersection with a ray.
A class for managing temporary objects.
virtual const labelList & faceOwner() const
Return face owner.
A patch is a list of labels that address the faces in the global face list.
T & ref() const
Return non-const reference or generate a fatal error.
virtual const faceList & faces() const
Return raw faces.
label findPatchID(const word &patchName) const
Find patch index given a name.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
mappedPatchBase(const polyPatch &)
Construct from patch.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
DynamicField< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
void collectSamples(const pointField &facePoints, pointField &, labelList &patchFaceProcs, labelList &patchFaces, pointField &patchFc) const
Collect single list of samples and originating processor+face.
const sampleMode mode_
What to sample.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
#define InfoInFunction
Report an information message using Foam::Info.