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;
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");
856 faceAreaWeightAMI::typeName,
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"));
1086 offsets_ = readListOrField(
"offsets", dict, patch_.size());
1092 distance_ = dict.
lookup<scalar>(
"distance");
1097 else if (dict.
found(
"offset"))
1099 offsetMode_ = UNIFORM;
1102 else if (dict.
found(
"offsets"))
1104 offsetMode_ = NONUNIFORM;
1105 offsets_ = readListOrField(
"offsets", dict, patch_.size());
1107 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)
1143 <<
"Construct from sampleMode and dictionary only applicable for " 1144 <<
" collocated patches in modes " 1145 << sampleModeNames_[NEARESTPATCHFACE] <<
',' 1146 << sampleModeNames_[NEARESTPATCHFACEAMI]
1150 if (!coupleGroup_.valid())
1152 if (sampleRegion_.empty())
1155 sampleRegion_ = patch_.boundaryMesh().mesh().name();
1202 offsetMode_ == NONUNIFORM
1245 const polyMesh& nbrMesh = sampleMesh();
1252 <<
"Cannot find patch " << samplePatch()
1253 <<
" in region " << sampleRegion_ <<
endl 1270 switch (offsetMode_)
1299 return samplePoints(facePoints(patch_));
1344 const point& basePoint = p[f[fp0]];
1346 label fp = f.fcIndex(fp0);
1347 for (
label i = 2; i < f.size(); i++)
1349 const point& thisPoint = p[f[fp]];
1350 label nextFp = f.fcIndex(fp);
1351 const point& nextPoint = p[f[nextFp]];
1353 const triPointRef tri(basePoint, thisPoint, nextPoint);
1386 writeEntry(os,
"sampleMode", sampleModeNames_[mode_]);
1387 if (!sampleRegion_.empty())
1389 writeEntry(os,
"sampleRegion", sampleRegion_);
1391 if (!samplePatch_.empty())
1395 coupleGroup_.write(os);
1399 offsetMode_ == UNIFORM
1401 && (mode_ == NEARESTPATCHFACE || mode_ == NEARESTPATCHFACEAMI)
1408 writeEntry(os,
"offsetMode", offsetModeNames_[offsetMode_]);
1410 switch (offsetMode_)
1429 if (mode_ == NEARESTPATCHFACEAMI)
1436 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.
labelList first(const UList< labelPair > &p)
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)
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.
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))
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
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.
Class containing processor-to-processor mapping information.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
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.