47 patchNeighbourFieldPtr_(nullptr)
62 patchNeighbourFieldPtr_(nullptr)
64 if (!isA<cyclicAMIFvPatch>(
p))
67 <<
"\n patch type '" <<
p.type()
68 <<
"' not constraint type '" << typeName <<
"'" 69 <<
"\n for patch " <<
p.name()
70 <<
" of field " << this->internalField().name()
71 <<
" in file " << this->internalField().objectPath()
75 if (cacheNeighbourField())
78 const auto* hasNeighbValue =
79 dict.findEntry(
"neighbourValue", keyType::LITERAL);
83 patchNeighbourFieldPtr_.reset
85 new Field<Type>(*hasNeighbValue,
p.size())
91 if (!this->readValueEntry(
dict))
101 GeometricField<Type, fvPatchField, volMesh>::
102 Boundary::localConsistency;
104 const int oldConsistency = consistency;
107 this->
evaluate(UPstream::commsTypes::nonBlocking);
109 consistency = oldConsistency;
113 this->extrapolateInternal();
122 const cyclicAMIFvPatchField<Type>& ptf,
124 const DimensionedField<Type, volMesh>& iF,
125 const fvPatchFieldMapper& mapper
128 cyclicAMILduInterfaceField(),
129 coupledFvPatchField<Type>(ptf,
p, iF, mapper),
130 cyclicAMIPatch_(
refCast<const cyclicAMIFvPatch>(
p)),
131 patchNeighbourFieldPtr_(nullptr)
141 if (!isA<cyclicAMIFvPatch>(this->
patch()))
144 <<
"\n patch type '" << p.type()
145 <<
"' not constraint type '" << typeName <<
"'" 146 <<
"\n for patch " <<
p.name()
147 <<
" of field " << this->internalField().name()
148 <<
" in file " << this->internalField().objectPath()
151 if (
debug && !ptf.all_ready())
154 <<
"Outstanding request(s) on patch " << cyclicAMIPatch_.name()
163 const cyclicAMIFvPatchField<Type>& ptf
166 cyclicAMILduInterfaceField(),
167 coupledFvPatchField<Type>(ptf),
168 cyclicAMIPatch_(ptf.cyclicAMIPatch_),
169 patchNeighbourFieldPtr_(nullptr)
171 if (
debug && !ptf.all_ready())
174 <<
"Outstanding request(s) on patch " << cyclicAMIPatch_.name()
183 const cyclicAMIFvPatchField<Type>& ptf,
184 const DimensionedField<Type, volMesh>& iF
187 cyclicAMILduInterfaceField(),
188 coupledFvPatchField<Type>(ptf, iF),
189 cyclicAMIPatch_(ptf.cyclicAMIPatch_),
190 patchNeighbourFieldPtr_(nullptr)
192 if (
debug && !ptf.all_ready())
195 <<
"Outstanding request(s) on patch " << cyclicAMIPatch_.name()
210 UPstream::finishedRequests
212 recvRequests_.start(),
217 recvRequests_.
clear();
223 UPstream::finishedRequests
225 sendRequests_.start(),
230 sendRequests_.clear();
243 UPstream::finishedRequests
245 recvRequests_.start(),
250 recvRequests_.clear();
254 UPstream::finishedRequests
256 sendRequests_.start(),
261 sendRequests_.clear();
279 patchNeighbourFieldPtr_.reset(
nullptr);
291 patchNeighbourFieldPtr_.reset(
nullptr);
299 const Field<Type>& iField
304 const cyclicAMIFvPatch& neighbPatch = cyclicAMIPatch_.
neighbPatch();
305 const labelUList& nbrFaceCells = neighbPatch.faceCells();
307 Field<Type> pnf(iField, nbrFaceCells);
308 Field<Type> defaultValues;
310 if (cyclicAMIPatch_.applyLowWeightCorrection())
312 defaultValues = Field<Type>(iField, cyclicAMIPatch_.faceCells());
315 tmp<Field<Type>> tpnf = cyclicAMIPatch_.interpolate(pnf, defaultValues);
319 transform(tpnf.ref(), forwardT(), tpnf());
331 GeometricField<Type, fvPatchField, volMesh>::Boundary::localConsistency
341 if (this->ownerAMI().distributed() && cacheNeighbourField())
346 <<
"Outstanding recv request(s) on patch " 347 << cyclicAMIPatch_.name()
348 <<
" field " << this->internalField().name()
352 const auto& fvp = this->
patch();
356 patchNeighbourFieldPtr_
357 && !fvp.boundaryMesh().mesh().upToDatePoints(this->internalField())
366 patchNeighbourFieldPtr_.reset(
nullptr);
370 if (!patchNeighbourFieldPtr_)
380 patchNeighbourFieldPtr_.reset
382 patchNeighbourField(this->primitiveField()).ptr()
407 return patchNeighbourFieldPtr_();
412 return patchNeighbourField(this->primitiveField());
421 const GeometricField<Type, fvPatchField, volMesh>&
fld =
422 static_cast<const GeometricField<Type, fvPatchField, volMesh>&
> 424 this->primitiveField()
427 return refCast<const cyclicAMIFvPatchField<Type>>
429 fld.boundaryField()[cyclicAMIPatch_.neighbPatchID()]
440 if (!this->updated())
442 this->updateCoeffs();
445 if (this->ownerAMI().distributed() && cacheNeighbourField())
454 if (commsType != UPstream::commsTypes::nonBlocking)
457 patchNeighbourFieldPtr_.reset(
nullptr);
465 const cyclicAMIFvPatch& neighbPatch = cyclicAMIPatch_.neighbPatch();
466 const labelUList& nbrFaceCells = neighbPatch.faceCells();
467 const Field<Type> pnf(this->primitiveField(), nbrFaceCells);
469 const cyclicAMIPolyPatch& cpp = cyclicAMIPatch_.cyclicAMIPatch();
472 if (!recvRequests_.empty())
475 <<
"Outstanding recv request(s) on patch " 476 << cyclicAMIPatch_.name()
477 <<
" field " << this->internalField().name()
482 sendRequests_.clear();
499 const Pstream::commsTypes commsType
502 if (!this->updated())
504 this->updateCoeffs();
507 const auto& AMI = this->ownerAMI();
509 if (AMI.distributed() && cacheNeighbourField())
512 if (commsType != UPstream::commsTypes::nonBlocking)
515 <<
"Can only evaluate distributed AMI with nonBlocking" 519 patchNeighbourFieldPtr_.reset(
nullptr);
521 const cyclicAMIPolyPatch& cpp = cyclicAMIPatch_.cyclicAMIPatch();
523 Field<Type> defaultValues;
524 if (AMI.applyLowWeightCorrection())
526 defaultValues = this->patchInternalField();
536 patchNeighbourFieldPtr_.reset
548 recvRequests_.clear();
550 auto& patchNeighbourField = patchNeighbourFieldPtr_.ref();
555 transform(patchNeighbourField, forwardT(), patchNeighbourField);
577 if (this->ownerAMI().distributed())
580 if (commsType != UPstream::commsTypes::nonBlocking)
583 <<
"Can only evaluate distributed AMI with nonBlocking" 588 lduAddr.
patchAddr(cyclicAMIPatch_.neighbPatchID());
593 transformCoupleField(pnf, cmpt);
595 const cyclicAMIPolyPatch& cpp = cyclicAMIPatch_.cyclicAMIPatch();
598 if (!recvRequests_.empty())
601 <<
"Outstanding recv request(s) on patch " 602 << cyclicAMIPatch_.name()
603 <<
" field " << this->internalField().name()
608 sendRequests_.clear();
620 this->updatedMatrix(
false);
644 const auto& AMI = this->ownerAMI();
648 if (AMI.distributed())
650 if (commsType != UPstream::commsTypes::nonBlocking)
653 <<
"Can only evaluate distributed AMI with nonBlocking" 658 if (AMI.applyLowWeightCorrection())
663 const cyclicAMIPolyPatch& cpp = cyclicAMIPatch_.cyclicAMIPatch();
668 solveScalarField::null(),
675 recvRequests_.
clear();
680 if (cyclicAMIPatch_.applyLowWeightCorrection())
686 lduAddr.
patchAddr(cyclicAMIPatch_.neighbPatchID());
691 transformCoupleField(pnf, cmpt);
693 pnf = cyclicAMIPatch_.interpolate(pnf, defaultValues);
697 this->addToInternalField(result, !
add, faceCells, coeffs, pnf);
699 this->updatedMatrix(
true);
715 const auto& AMI = this->ownerAMI();
717 if (AMI.distributed())
719 if (commsType != UPstream::commsTypes::nonBlocking)
722 <<
"Can only evaluate distributed AMI with nonBlocking" 727 lduAddr.
patchAddr(cyclicAMIPatch_.neighbPatchID());
729 Field<Type> pnf(psiInternal, nbrFaceCells);
732 transformCoupleField(pnf);
734 const cyclicAMIPolyPatch& cpp = cyclicAMIPatch_.cyclicAMIPatch();
737 if (!recvRequests_.empty())
740 <<
"Outstanding recv request(s) on patch " 741 << cyclicAMIPatch_.name()
742 <<
" field " << this->internalField().name()
747 sendRequests_.clear();
759 this->updatedMatrix(
false);
782 const auto& AMI = this->ownerAMI();
786 if (AMI.distributed())
788 if (commsType != UPstream::commsTypes::nonBlocking)
791 <<
"Can only evaluate distributed AMI with nonBlocking" 795 const cyclicAMIPolyPatch& cpp = cyclicAMIPatch_.cyclicAMIPatch();
797 Field<Type> defaultValues;
798 if (AMI.applyLowWeightCorrection())
800 defaultValues = Field<Type>(psiInternal, faceCells);
813 recvRequests_.
clear();
818 lduAddr.
patchAddr(cyclicAMIPatch_.neighbPatchID());
820 pnf = Field<Type>(psiInternal, nbrFaceCells);
823 transformCoupleField(pnf);
825 Field<Type> defaultValues;
826 if (cyclicAMIPatch_.applyLowWeightCorrection())
828 defaultValues = Field<Type>(psiInternal, faceCells);
831 pnf = cyclicAMIPatch_.interpolate(pnf, defaultValues);
835 this->addToInternalField(result, !
add, faceCells, coeffs, pnf);
837 this->updatedMatrix(
true);
849 if (this->cyclicAMIPatch().owner())
851 const label index = this->
patch().index();
853 const label globalPatchID =
881 label globalFaceI =
faceMap[j];
883 const scalar boundCorr = -bndCoeffs[subFaceI];
884 const scalar intCorr = -intCoeffs[subFaceI];
886 matrix.
upper()[globalFaceI] += boundCorr;
887 matrix.
diag()[u[globalFaceI]] -= intCorr;
888 matrix.
diag()[l[globalFaceI]] -= boundCorr;
892 matrix.
lower()[globalFaceI] += intCorr;
900 if (matrix.
psi(mat).mesh().fluxRequired(this->internalField().
name()))
904 globalPatchID, intCoeffs*pTraits<Type>::one
908 globalPatchID, bndCoeffs*pTraits<Type>::one
911 const label nbrPathID =
912 cyclicAMIPatch_.cyclicAMIPatch().neighbPatchID();
914 const label nbrGlobalPatchID =
920 nbrGlobalPatchID, intCoeffs*pTraits<Type>::one
924 nbrGlobalPatchID, bndCoeffs*pTraits<Type>::one
935 fvMatrix<Type>& matrix,
936 const Field<scalar>& coeffs,
940 const label index(this->
patch().index());
942 const label nSubFaces
944 matrix.lduMeshAssembly().cellBoundMap()[mat][index].size()
947 auto tmapCoeffs = tmp<Field<scalar>>
::New(nSubFaces,
Zero);
948 auto& mapCoeffs = tmapCoeffs.ref();
951 cyclicAMIPatch_.cyclicAMIPatch().AMI().srcWeights();
957 for(label i=0; i<w.size(); i++)
959 const label localFaceId =
960 matrix.lduMeshAssembly().facePatchFaceMap()[mat][index][subFaceI];
961 mapCoeffs[subFaceI] = w[i]*coeffs[localFaceId];
971 template<
class Type2>
974 const refPtr<mapDistribute>& mapPtr,
977 List<Type2>& expandedData
984 mapPtr().distribute(work);
991 UIndirectList<typename Type2::value_type>(work, slots)
1002 UIndirectList<typename Type2::value_type>(data, slots)
1009 template<
class Type>
1013 fvPatchField<Type>::writeValueEntry(
os);
1015 if (patchNeighbourFieldPtr_)
1017 patchNeighbourFieldPtr_->writeEntry(
"neighbourValue",
os);
1024 template<
class Type>
1038 const auto* cycPtr = isA<cyclicAMIFvPatchField<Type>>(ptf);
1041 const auto& cyc = *cycPtr;
1044 cyc.patchNeighbourFieldPtr_
1045 && cyc.patchNeighbourFieldPtr_->size() == this->size()
1048 const auto& cycPnf = cyc.patchNeighbourFieldPtr_();
1049 if (patchNeighbourFieldPtr_)
1052 patchNeighbourFieldPtr_() = cycPnf;
1057 patchNeighbourFieldPtr_.reset(
new Field<Type>(cycPnf));
1062 patchNeighbourFieldPtr_.reset(
nullptr);
1067 patchNeighbourFieldPtr_.reset(
nullptr);
1072 template<
class Type>
1075 const fvPatchField<Type>& ptf
1086 const auto* cycPtr = isA<cyclicAMIFvPatchField<Type>>(ptf);
1089 const auto& cyc = *cycPtr;
1092 cyc.patchNeighbourFieldPtr_
1093 && cyc.patchNeighbourFieldPtr_->size() == this->size()
1096 const auto& cycPnf = cyc.patchNeighbourFieldPtr_();
1097 if (patchNeighbourFieldPtr_)
1100 patchNeighbourFieldPtr_() = cycPnf;
1105 patchNeighbourFieldPtr_.reset(
new Field<Type>(cycPnf));
1110 patchNeighbourFieldPtr_.reset(
nullptr);
1115 patchNeighbourFieldPtr_.reset(
nullptr);
List< scalar > scalarList
List of scalar.
const scalarField & diag() const
virtual bool ready() const
Are all (receive) data available?
errorManipArg< error, int > exit(error &err, const int errNo=1)
Field< solveScalar > solveScalarField
commsTypes
Communications types.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
virtual void initInterfaceMatrixUpdate(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Initialise neighbour matrix update.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual void manipulateMatrix(fvMatrix< Type > &m, const label iMatrix, const direction cmpt)
Manipulate matrix.
const lduPrimitiveMeshAssembly & lduMeshAssembly()
Return optional lduAdressing.
Cyclic patch for Arbitrary Mesh Interface (AMI)
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
Smooth ATC in cells next to a set of patches supplied by type.
void push_back(const T &val)
Append an element at the end of the list.
List< labelList > labelListList
List of labelList.
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
UList< label > labelUList
A UList of labels.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
#define forAll(list, i)
Loop across all elements in list.
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Abstract base class for cyclic AMI coupled interfaces.
const GeometricField< Type, fvPatchField, volMesh > & psi(const label i=0) const
Return psi.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
void clear()
Clear the list, i.e. set size to zero.
List< scalarList > scalarListList
List of scalarList.
virtual void write(Ostream &os) const
Write.
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
A FieldMapper for finite-volume patch fields.
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
String evaluation with specified (positive, non-zero) field width.
virtual const labelUList & patchAddr(const label patchNo) const =0
Return patch to internal addressing given patch number.
const scalarField & lower() const
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
errorManip< error > abort(error &err)
Abstract base class for coupled patches.
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
bool asymmetric() const noexcept
Matrix is asymmetric (ie, full)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const scalarField & upper() const
const lduAddressing & lduAddr() const
Return the LDU addressing.
virtual const cyclicAMIFvPatch & neighbPatch() const
Return a reference to the neighbour patch.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const std::string patch
OpenFOAM patch number as a std::string.
const cyclicAMIFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
const FieldField< Field, Type > & internalCoeffs() const noexcept
fvBoundary scalar field containing pseudo-matrix coeffs for internal cells
The class contains the addressing required by the lduMatrix: upper, lower and losort.
const FieldField< Field, Type > & boundaryCoeffs() const noexcept
fvBoundary scalar field containing pseudo-matrix coeffs for boundary cells
cyclicAMIFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
List< label > labelList
A List of labels.
A class for managing temporary objects.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
This boundary condition enforces a cyclic condition between a pair of boundaries, whereby communicati...
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)