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())
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.
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.
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.
const double e
Elementary charge.
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.
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.
static const meshSearchMeshObject & New(const polyMesh &mesh)
virtual const pointField & points() const
Return raw points.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
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))
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.
mode_t mode(const fileName &, const bool followLink=true)
Return the file mode.
const word & constant() const
Return constant name.
cachedRandom rndGen(label(0), -1)
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.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
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...
Simple random number generator.
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...
const Field< PointType > & localPoints() const
Return pointField of points in patch.
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:
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_
fileName::Type type(const fileName &, const bool followLink=true)
Return the file type: DIRECTORY or FILE.
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")
A List with indirect addressing.
sampleMode
Mesh items to sample.
label start() const
Return start label of this patch in the polyMesh face list.
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.
Mesh consisting of general polyhedral cells.
scalar distance() const
Return distance to hit.
const point & min() const
Minimum describing the bounding box.
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.