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")
213 "mappedPatchBase::findSamples(const pointField&," 214 " labelList&, labelList&, pointField&) const" 215 ) <<
"No need to supply a patch name when in " 224 const point& sample = samples[sampleI];
230 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
243 nearest[sampleI].second().first() =
magSqr(cc-sample);
250 case NEARESTONLYCELL:
252 if (samplePatch_.size() && samplePatch_ !=
"none")
256 "mappedPatchBase::findSamples(const pointField&," 257 " labelList&, labelList&, pointField&) const" 258 ) <<
"No need to supply a patch name when in " 267 const point& sample = samples[sampleI];
269 nearest[sampleI].
first() = tree.findNearest(sample,
sqr(GREAT));
270 nearest[sampleI].second().first() =
magSqr 272 nearest[sampleI].first().hitPoint()
280 case NEARESTPATCHFACE:
290 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
307 patchBb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
308 patchBb.max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
326 const point& sample = samples[sampleI];
329 nearInfo = boundaryTree.findNearest
337 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
338 nearest[sampleI].second().second() =
345 nearest[sampleI].second().first() =
magSqr(fc-sample);
346 nearest[sampleI].second().second() =
354 case NEARESTPATCHPOINT:
364 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
379 patchBb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
380 patchBb.max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
397 const point& sample = samples[sampleI];
400 nearInfo = boundaryTree.findNearest
408 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
409 nearest[sampleI].second().second() =
416 nearest[sampleI].second().first() =
magSqr(pt-sample);
417 nearest[sampleI].second().second() =
427 if (samplePatch().size() && samplePatch() !=
"none")
431 "mappedPatchBase::findSamples(const pointField&," 432 " labelList&, labelList&, pointField&) const" 433 ) <<
"No need to supply a patch name when in " 443 const point& sample = samples[sampleI];
449 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
462 nearest[sampleI].second().first() =
magSqr(fc-sample);
469 case NEARESTPATCHFACEAMI:
490 Info<<
"mappedPatchBase::findSamples on mesh " << sampleRegion()
494 label procI = nearest[sampleI].second().second();
495 label localI = nearest[sampleI].first().index();
497 Info<<
" " << sampleI <<
" coord:"<< samples[sampleI]
498 <<
" found on processor:" << procI
499 <<
" in local cell/face/point:" << localI
500 <<
" with location:" << nearest[sampleI].
first().rawPoint()
512 if (!nearest[sampleI].first().hit())
514 sampleProcs[sampleI] = -1;
515 sampleIndices[sampleI] = -1;
520 sampleProcs[sampleI] = nearest[sampleI].second().second();
521 sampleIndices[sampleI] = nearest[sampleI].
first().index();
522 sampleLocations[sampleI] = nearest[sampleI].
first().hitPoint();
530 static bool hasWarned =
false;
542 const pointField offsettedPoints(samplePoints(patchPoints()));
548 mode_ == NEARESTPATCHFACE
549 && sampleRegion() == patch_.boundaryMesh().mesh().name()
550 && samplePatch() == patch_.name()
555 bool coincident = (
gAverage(
mag(d)) <= ROOTVSMALL);
557 if (sampleMyself && coincident)
561 "mappedPatchBase::mappedPatchBase\n" 563 " const polyPatch& pp,\n" 564 " const word& sampleRegion,\n" 565 " const sampleMode mode,\n" 566 " const word& samplePatch,\n" 567 " const vector& offset\n" 569 ) <<
"Invalid offset " << d <<
endl 570 <<
"Offset is the vector added to the patch face centres to" 571 <<
" find the patch face supplying the data." <<
endl 572 <<
"Setting it to " << d
573 <<
" on the same patch, on the same region" 574 <<
" will find the faces themselves which does not make sense" 575 <<
" for anything but testing." <<
endl 576 <<
"patch_:" << patch_.
name() <<
endl 577 <<
"sampleRegion_:" << sampleRegion() <<
endl 578 <<
"mode_:" << sampleModeNames_[mode_] <<
endl 579 <<
"samplePatch_:" << samplePatch() <<
endl 580 <<
"offsetMode_:" << offsetModeNames_[offsetMode_] <<
endl;
601 findSamples(mode_, samples, sampleProcs, sampleIndices, sampleLocations);
605 if (mode_ == NEARESTCELL)
608 forAll(sampleProcs, sampleI)
610 if (sampleProcs[sampleI] == -1)
623 "mappedPatchBase::mappedPatchBase\n" 625 " const polyPatch& pp,\n" 626 " const word& sampleRegion,\n" 627 " const sampleMode mode,\n" 628 " const word& samplePatch,\n" 629 " const vector& offset\n" 631 ) <<
"Did not find " << nNotFound
632 <<
" out of " << sampleProcs.
size() <<
" total samples." 633 <<
" Sampling these on owner cell centre instead." <<
endl 634 <<
"On patch " << patch_.
name()
635 <<
" on region " << sampleRegion()
636 <<
" in mode " << sampleModeNames_[mode_] <<
endl 637 <<
"with offset mode " << offsetModeNames_[offsetMode_]
638 <<
". Suppressing further warnings from " <<
type() <<
endl;
647 forAll(sampleProcs, sampleI)
649 if (sampleProcs[sampleI] == -1)
652 subSamples.
append(samples[sampleI]);
702 patch_.boundaryMesh().mesh().time().path()
706 Pout<<
"Dumping mapping as lines from patch faceCentres to" 707 <<
" sampled cell/faceCentres/points to file " << str.
name()
718 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
723 mapPtr_.reset(
new mapDistribute(sampleProcs, patchFaceProcs));
755 mapPtr_().constructSize() = patch_.
size();
761 forAll(constructMap, procI)
763 const labelList& map = constructMap[procI];
767 label faceI = map[i];
769 if (used[faceI] == 0)
776 <<
"On patch " << patch_.name()
777 <<
" patchface " << faceI
778 <<
" is assigned to more than once." 785 if (used[faceI] == 0)
788 <<
"On patch " << patch_.name()
789 <<
" patchface " << faceI
790 <<
" is never assigned to." 801 const word surfType(surfDict_.lookupOrDefault<
word>(
"type",
"none"));
803 if (!surfPtr_.valid() && surfType !=
"none")
805 word surfName(surfDict_.lookupOrDefault(
"name", patch_.name()));
842 const polyPatch& nbr = samplePolyPatch();
846 OFstream os(patch_.name() +
"_neighbourPatch-org.obj");
860 OFstream osN(patch_.name() +
"_neighbourPatch-trans.obj");
863 OFstream osO(patch_.name() +
"_ownerPatch.obj");
903 token firstToken(is);
912 else if (firstToken.
wordToken() ==
"nonuniform")
915 if (fld.
size() != size)
919 "mappedPatchBase::readListOrField" 920 "(const word& keyword, const dictionary&, const label)",
922 ) <<
"size " << fld.
size()
923 <<
" is not equal to the given value of " << size
931 "mappedPatchBase::readListOrField" 932 "(const word& keyword, const dictionary&, const label)",
934 ) <<
"expected keyword 'uniform' or 'nonuniform', found " 945 "mappedPatchBase::readListOrField" 946 "(const word& keyword, const dictionary&, const label)",
948 ) <<
"expected keyword 'uniform' or 'nonuniform', " 949 "assuming List format for backwards compatibility." 950 "Foam version 2.0." <<
endl;
969 sampleRegion_(patch_.boundaryMesh().mesh().name()),
970 mode_(NEARESTPATCHFACE),
973 offsetMode_(UNIFORM),
975 offsets_(pp.size(), offset_),
977 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
989 const word& sampleRegion,
991 const word& samplePatch,
996 sampleRegion_(sampleRegion),
998 samplePatch_(samplePatch),
1000 offsetMode_(NONUNIFORM),
1004 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1016 const word& sampleRegion,
1018 const word& samplePatch,
1023 sampleRegion_(sampleRegion),
1025 samplePatch_(samplePatch),
1027 offsetMode_(UNIFORM),
1031 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1043 const word& sampleRegion,
1045 const word& samplePatch,
1046 const scalar distance
1050 sampleRegion_(sampleRegion),
1052 samplePatch_(samplePatch),
1054 offsetMode_(NORMAL),
1057 distance_(distance),
1058 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1075 mode_(sampleModeNames_.read(dict.
lookup(
"sampleMode"))),
1078 offsetMode_(UNIFORM),
1082 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1089 if (!coupleGroup_.valid())
1091 if (sampleRegion_.empty())
1094 sampleRegion_ = patch_.boundaryMesh().mesh().name();
1099 if (dict.
found(
"offsetMode"))
1101 offsetMode_ = offsetModeNames_.read(dict.
lookup(
"offsetMode"));
1114 offsets_ = readListOrField(
"offsets", dict, patch_.
size());
1125 else if (dict.
found(
"offset"))
1127 offsetMode_ = UNIFORM;
1130 else if (dict.
found(
"offsets"))
1132 offsetMode_ = NONUNIFORM;
1134 offsets_ = readListOrField(
"offsets", dict, patch_.
size());
1136 else if (mode_ != NEARESTPATCHFACE && mode_ != NEARESTPATCHFACEAMI)
1140 "mappedPatchBase::mappedPatchBase\n" 1142 " const polyPatch&,\n" 1143 " const dictionary&\n" 1146 ) <<
"Please supply the offsetMode as one of " 1165 offsetMode_(UNIFORM),
1169 sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1176 if (mode != NEARESTPATCHFACE && mode != NEARESTPATCHFACEAMI)
1180 "mappedPatchBase::mappedPatchBase\n" 1182 " const polyPatch&,\n" 1183 " const sampleMode,\n" 1184 " const dictionary&\n" 1187 ) <<
"Construct from sampleMode and dictionary only applicable for " 1188 <<
" collocated patches in modes " 1189 << sampleModeNames_[NEARESTPATCHFACE] <<
',' 1190 << sampleModeNames_[NEARESTPATCHFACEAMI]
1195 if (!coupleGroup_.valid())
1197 if (sampleRegion_.empty())
1200 sampleRegion_ = patch_.boundaryMesh().mesh().name();
1247 offsetMode_ == NONUNIFORM
1290 const polyMesh& nbrMesh = sampleMesh();
1297 <<
"Cannot find patch " << samplePatch()
1298 <<
" in region " << sampleRegion_ <<
endl 1315 switch (offsetMode_)
1344 return samplePoints(facePoints(patch_));
1389 const point& basePoint = p[f[fp0]];
1392 for (
label i = 2; i < f.size(); i++)
1394 const point& thisPoint = p[f[fp]];
1396 const point& nextPoint = p[f[nextFp]];
1398 const triPointRef tri(basePoint, thisPoint, nextPoint);
1431 os.
writeKeyword(
"sampleMode") << sampleModeNames_[mode_]
1433 if (!sampleRegion_.empty())
1438 if (!samplePatch_.empty())
1443 coupleGroup_.write(os);
1447 offsetMode_ == UNIFORM
1449 && (mode_ == NEARESTPATCHFACE || mode_ == NEARESTPATCHFACEAMI)
1456 os.
writeKeyword(
"offsetMode") << offsetModeNames_[offsetMode_]
1459 switch (offsetMode_)
1469 offsets_.writeEntry(
"offsets", os);
1480 if (mode_ == NEARESTPATCHFACEAMI)
1488 if (!surfDict_.empty())
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
vector offset_
Offset vector (uniform)
Simple random number generator.
word samplePatch_
Patch (if in sampleMode NEARESTPATCH*)
cachedRandom rndGen(label(0),-1)
A 2-tuple for storing two objects of different types.
const point & min() const
Minimum describing the bounding box.
void collectSamples(const pointField &facePoints, pointField &, labelList &patchFaceProcs, labelList &patchFaces, pointField &patchFc) const
Collect single list of samples and originating processor+face.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
vector point
Point is a vector.
mode_t mode(const fileName &)
Return the file mode.
const polyMesh & sampleMesh() const
Get the region mesh.
dimensioned< scalar > mag(const dimensioned< Type > &)
const labelList & tetBasePtIs() const
Return the tetBasePtIs.
versionNumber version() const
Return the stream version.
tmp< pointField > samplePoints() const
Get the sample points.
tmp< pointField > facePoints(const polyPatch &) const
Get the points from face-centre-decomposition face centres.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
static const meshSearchMeshObject & New(const polyMesh &mesh)
Class containing processor-to-processor mapping information.
const Point & hitPoint() const
Return hit point.
pointHit intersection(const point &p, const vector &q, const intersection::algorithm alg, const scalar tol=0.0) const
Fast intersection with a ray.
const coupleGroupIdentifier coupleGroup_
PatchGroup (if in sampleMode NEARESTPATCH*)
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
A class for handling words, derived from string.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Standard boundBox + extra functionality for use in octree.
void size(const label)
Override size to be inconsistent with allocated storage.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
word sampleRegion_
Region to sample.
errorManipArg< error, int > exit(error &err, const int errNo=1)
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
PointIndexHit< point > pointIndexHit
static void scatterList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Scatter data. Reverse of gatherList.
void findSamples(const sampleMode mode, const pointField &, labelList &sampleProcs, labelList &sampleIndices, pointField &sampleLocations) const
Find cells/faces containing samples.
virtual ~mappedPatchBase()
Destructor.
const Type1 & first() const
Return first.
const vectorField & cellCentres() const
bool hit() const
Is there a hit.
label findNearestFace(const point &location, const label seedFaceI=-1, const bool useTreeSearch=true) const
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Encapsulation of data needed to search for faces.
A list of keyword definitions, which are a keyword followed by any number of values (e...
const word & wordToken() const
label size() const
Return number of elements in list.
T & first()
Return the first element of the list.
label index() const
Return index.
label facePoint(const int facei, const block &block, const label i, const label j)
const word & constant() const
Return constant name.
vectorField pointField
pointField is a vectorField.
A triangle primitive used to calculate face normals and swept volumes.
#define IOWarningIn(functionName, ios)
Report an IO warning using Foam::Warning.
const Point & hitPoint() const
Return hit point.
A patch is a list of labels that address the faces in the global face list.
offsetMode offsetMode_
How to obtain samples.
void calcAMI() const
Calculate AMI interpolator.
dictionary surfDict_
Dictionary storing projection surface description.
vectorField offsets_
Offset vector (nonuniform)
wordList names() const
Return a list of patch names.
A face is a list of labels corresponding to mesh vertices.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
const double e
Elementary charge.
static autoPtr< searchableSurface > New(const word &surfaceType, const IOobject &io, const dictionary &dict)
Return a reference to the selected searchableSurface.
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const polyPatch & samplePolyPatch() const
Get the patch on the region.
static wordList words()
The set of names as a list of words.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
#define WarningIn(functionName)
Report a warning using Foam::Warning.
static const NamedEnum< sampleMode, 6 > sampleModeNames_
offsetMode
How to project face centres.
const sampleMode mode_
What to sample.
void putBack(const token &)
Put back token.
virtual const pointField & points() const
Return raw points.
A List with indirect addressing.
static const NamedEnum< offsetMode, 3 > offsetModeNames_
const autoPtr< Foam::searchableSurface > & surfPtr() const
Return a pointer to the AMI projection surface.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
label size() const
Return the number of elements in the list.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
MeshObject wrapper around meshSearch(mesh).
static tmp< pointField > readListOrField(const word &keyword, const dictionary &dict, const label size)
Helper to read field or non-uniform list from dictionary.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
Macros for easy insertion into run-time selection tables.
A token holds items read from Istream.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
errorManip< error > abort(error &err)
virtual const labelList & faceOwner() const
Return face owner.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
scalar distance_
Offset distance (normal)
mappedPatchBase(const polyPatch &)
Construct from patch.
virtual const fileName & name() const
Return the name of the stream.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
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 ))
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Initialise the NamedEnum HashTable from the static list of names.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
A list of faces which address into the list of points.
scalar distance() const
Return distance to hit.
label start() const
Return start label of this patch in the polyMesh face list.
virtual const fileName & name() const
Return the name of the stream.
Mesh consisting of general polyhedral cells.
Traits class for primitives.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Type gAverage(const FieldField< Field, Type > &f)
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
const polyMesh & mesh() const
Return the mesh reference.
void setPoint(const Point &p)
A class for handling file names.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool hit() const
Is there a hit.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
static bool master(const label communicator=0)
Am I the master process.
sampleMode
Mesh items to sample.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
scalarField samples(nIntervals, 0)
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
A List obtained as a section of another List.
void calcMapping() const
Calculate mapping.
DynamicField< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
const Time & time() const
Return time.
virtual const faceList & faces() const
Return raw faces.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void writeOBJ(Ostream &os, const point &pt)
Write obj representation of point.
label findPatchID(const word &patchName) const
Find patch index given a name.
cellDecomposition
Enumeration defining the decomposition of the cell for.
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
A class for managing temporary objects.
const bool AMIReverse_
Flag to indicate that slave patch should be reversed for AMI.
const Field< PointType > & points() const
Return reference to global points.
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 pointIndexHit facePoint(const polyMesh &, const label faceI, const polyMesh::cellDecomposition)
Get a point on the face given a face decomposition method:
defineTypeNameAndDebug(combustionModel, 0)
bool sameRegion_
Same region.
dictionary subOrEmptyDict(const word &, const bool mustRead=false) const
Find and return a sub-dictionary as a copy, or.
prefixOSstream Pout(cout,"Pout")
const vectorField & faceCentres() const
virtual void write(Ostream &) const
Write as a dictionary.