Go to the documentation of this file.
31 #include "PatchTools.H"
46 cyclicPeriodicAMIPolyPatch,
78 refCast<const coupledPolyPatch>
91 <<
" has non-uniform separation vector "
93 <<
"This is not allowed inside " <<
type()
94 <<
" patch " <<
name()
98 if (periodicPatch.
forwardT().size() > 1)
102 <<
" has non-uniform transformation tensor "
104 <<
"This is not allowed inside " <<
type()
105 <<
" patch " <<
name()
140 if (!periodicPatch.size())
144 if (sep[procI].size())
175 if (!periodicPatch.size())
237 refCast<const coupledPolyPatch>
248 pointField nbrPoints0(neighbPatch().localPoints());
249 transformPosition(nbrPoints0);
255 if (nTransforms_ > nSectors_/2)
257 nTransforms_ -= nSectors_;
259 else if (nTransforms_ < - nSectors_/2)
261 nTransforms_ += nSectors_;
266 for (
label i = 0; i < nTransforms_; ++ i)
270 for (
label i = 0; i > nTransforms_; -- i)
287 Info<<
"cyclicPeriodicAMIPolyPatch::resetAMI : patch:" <<
name()
288 <<
" writing accumulated AMI to " << ownStr().name()
289 <<
" and " << neiStr().name() <<
endl;
313 SubList<face>(neighbPatch().localFaces(), neighbPatch().size()),
319 SubList<face>(neighbPatch().localFaces(), neighbPatch().size()),
334 AMILowWeightCorrection_,
341 label nTransformsOld(nTransforms_);
354 scalar srcSum(
gAverage(AMIPtr_->srcWeightsSum()));
355 scalar tgtSum(
gAverage(AMIPtr_->tgtWeightsSum()));
367 scalar srcSumDiff = 0;
371 Info<<
"cyclicPeriodicAMIPolyPatch::resetAMI : patch:" <<
name()
372 <<
" srcSum:" << srcSum
373 <<
" tgtSum:" << tgtSum
383 (1 - srcSum > matchTolerance())
384 || (1 - tgtSum > matchTolerance())
394 Info<<
"cyclicPeriodicAMIPolyPatch::resetAMI : patch:"
396 <<
" moving this side from:"
405 Info<<
"cyclicPeriodicAMIPolyPatch::resetAMI : patch:"
407 <<
" appending weights with untransformed slave side"
411 AMIPtr_->append(thisPatch, nbrPatch0);
424 Info<<
"cyclicPeriodicAMIPolyPatch::resetAMI : patch:"
426 <<
" moving neighbour side from:"
433 AMIPtr_->append(thisPatch0, nbrPatch);
441 const scalar srcSumNew =
gAverage(AMIPtr_->srcWeightsSum());
442 const scalar srcSumDiffNew = srcSumNew - srcSum;
444 if (srcSumDiffNew < srcSumDiff || srcSumDiffNew < SMALL)
448 srcSumDiff = srcSumDiffNew;
452 tgtSum =
gAverage(AMIPtr_->tgtWeightsSum());
460 Info<<
"cyclicPeriodicAMIPolyPatch::resetAMI : patch:" <<
name()
461 <<
" iteration:" << iter
462 <<
" srcSum:" << srcSum
463 <<
" tgtSum:" << tgtSum
483 nTransforms_ = (nTransforms_ + nTransformsOld)/2;
486 if (iter == maxIter_)
497 <<
"Patches " <<
name() <<
" and " << neighbPatch().name()
498 <<
" do not couple to within a tolerance of "
500 <<
" when transformed according to the periodic patch "
501 << periodicPatch.
name() <<
"." <<
nl
502 <<
"The current sum of weights are for owner " <<
name()
503 <<
" : " << srcSum <<
" and for neighbour "
504 << neighbPatch().name() <<
" : " << tgtSum <<
nl
505 <<
"This is only acceptable during post-processing"
506 <<
"; not during running. Improve your mesh or increase"
507 <<
" the 'matchTolerance' setting in the patch specification."
514 mag(srcSum - floor(srcSum + 0.5)) > srcSum*matchTolerance()
515 ||
mag(tgtSum - floor(tgtSum + 0.5)) > tgtSum*matchTolerance()
524 <<
"Patches " <<
name() <<
" and " << neighbPatch().name()
525 <<
" do not overlap an integer number of times when transformed"
526 <<
" according to the periodic patch "
527 << periodicPatch.
name() <<
"." <<
nl
528 <<
"The current matchTolerance : " << matchTolerance()
529 <<
", sum of owner weights : " << srcSum
530 <<
", sum of neighbour weights : " << tgtSum
532 <<
"This is only acceptable during post-processing"
533 <<
"; not during running. Improve your mesh or increase"
534 <<
" the 'matchTolerance' setting in the patch specification."
540 AMIPtr_->normaliseWeights(
true,
false);
551 srcWghtSum[faceI] =
sum(AMIPtr_->srcWeights()[faceI]);
552 tgtWghtSum[faceI] =
sum(AMIPtr_->tgtWeights()[faceI]);
556 <<
"AMI: Patch " <<
name()
557 <<
" sum(weights) min/max/average = "
558 <<
gMin(srcWghtSum) <<
", "
559 <<
gMax(srcWghtSum) <<
", "
562 <<
"AMI: Patch " << neighbPatch().
name()
563 <<
" sum(weights) min/max/average = "
564 <<
gMin(tgtWghtSum) <<
", "
565 <<
gMax(tgtWghtSum) <<
", "
581 const word& patchType,
587 periodicPatchID_(-1),
600 const word& patchType
604 periodicPatchName_(
dict.
lookup(
"periodicPatch")),
605 periodicPatchID_(-1),
620 periodicPatchID_(-1),
633 const label newStart,
634 const word& nbrPatchName
639 periodicPatchID_(-1),
657 periodicPatchID_(-1),
676 periodicPatchID_ = -1;
678 return periodicPatchID_;
681 if (periodicPatchID_ == -1)
685 if (periodicPatchID_ == -1)
688 <<
"Illegal periodicPatch name " << periodicPatchName_
689 <<
nl <<
"Valid patch names are "
695 refCast<const coupledPolyPatch>
701 return periodicPatchID_;
712 if (nTransforms_ != 0)
interpolationMethod
Enumeration specifying interpolation method.
const bMesh & mesh() const
virtual const vectorField & separation() const
If the planes are separated the separation vector.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
const Field< PointType > & points() const
Return reference to global points.
virtual bool owner() const
Does this side own the patch?
A class for handling words, derived from string.
A class for handling file names.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
OFstream which keeps track of vertices.
#define forAll(list, i)
Loop across all elements in list.
void writeOBJ(Ostream &os, label &vertI, const tetPoints &tet)
Type gAverage(const FieldField< Field, Type > &f)
virtual Ostream & write(const char)
Write character.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
static void scatterList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Scatter data. Reverse of gatherList.
A List obtained as a section of another List.
virtual const tensorField & forwardT() const
Return face transformation tensor.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Ostream & endl(Ostream &os)
Add newline and flush stream.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
void syncTransforms() const
Synchronise the periodic transformations.
const label maxIter_
Maximum number of attempts to match the AMI geometry.
dimensioned< scalar > mag(const dimensioned< Type > &)
virtual ~cyclicPeriodicAMIPolyPatch()
Destructor.
word periodicPatchName_
Periodic patch name.
Base class for Arbitrary Mesh Interface (AMI) methods.
void writeOBJ(const primitivePatch &p, OBJstream &str) const
Debug: write obj files of patch (collected on master)
dimensionSet transform(const dimensionSet &)
virtual bool parallel() const
Are the cyclic planes parallel.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
const fileName & rootPath() const
Return root path.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
#define SeriousErrorInFunction
Report an error message using Foam::SeriousError.
virtual void movePoints(const Field< PointType > &)
Correct patch after moving points.
virtual void resetAMI(const AMIPatchToPatchInterpolation::interpolationMethod &AMIMethod=AMIPatchToPatchInterpolation::imFaceAreaWeight) const
Reset the AMI interpolator.
const label nSectors_
Number of sectors in a rotationally periodic geometry (optional)
A list of keyword definitions, which are a keyword followed by any number of values (e....
Macros for easy insertion into run-time selection tables.
virtual label periodicPatchID() const
Periodic patch ID.
Ostream & indent(Ostream &os)
Indent stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
static bool master(const label communicator=0)
Am I the master process.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
cyclicPeriodicAMIPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType, const transformType transform=UNKNOWN)
Construct from (base couped patch) components.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
virtual void transformPosition(pointField &) const =0
Transform a patch-based position from other side to this side.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
label nTransforms_
Current number of transformations (+ve forward, -ve backward)
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set).
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
static const word null
An empty word.
@ imPartialFaceAreaWeight
void clear()
Delete object (if the pointer is valid) and set pointer to NULL.
void reset(T *=0)
If object pointer already set, delete object and set to given.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
label findPatchID(const polyPatchList &, const word &) const
Get index of polypatch by name.
virtual const boolList & collocated() const
Are faces collocated. Either size 0,1 or length of patch.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
const fileName & globalCaseName() const
Return global case name.
Type gMin(const FieldField< Field, Type > &f)
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Cyclic patch for periodic Arbitrary Mesh Interface (AMI)
defineTypeNameAndDebug(combustionModel, 0)
virtual const fileName & name() const
Return the name of the stream.
const word & name() const
Return name.
Type gMax(const FieldField< Field, Type > &f)
word name(const complex &)
Return a string representation of a complex.
A list of faces which address into the list of points.
Cyclic patch for Arbitrary Mesh Interface (AMI)