67 const VolField<Type>& cvf =
68 static_cast<const VolField<Type>&
>(this->internalField());
70 VolField<Type>& vf =
const_cast<VolField<Type>&
>(cvf);
72 typename VolField<Type>::Boundary& bf = vf.boundaryFieldRef();
75 label nPatch = bf.size();
76 reduce(nPatch, maxOp<label>());
78 offsets_.setSize(nPatch);
81 offsets_[i].setSize(Pstream::nProcs());
90 externalCoupledMixedFvPatchField<Type>& pf =
91 refCast<externalCoupledMixedFvPatchField<Type>>(bf[
patchi]);
93 offsets_[
patchi][Pstream::myProcNo()] = pf.size();
106 int tag = Pstream::msgType() + 1;
109 Pstream::gatherList(offsets_[i], tag);
110 Pstream::scatterList(offsets_[i], tag);
113 label patchOffset = 0;
117 List<label>& procOffsets = offsets_[
patchi];
119 forAll(procOffsets, proci)
121 label o = procOffsets[proci];
124 procOffsets[proci] = patchOffset + sumOffset;
128 patchOffset += sumOffset;
140 int tag = Pstream::msgType() + 1;
142 const label proci = Pstream::myProcNo();
143 const polyPatch&
p = this->patch().patch();
144 const polyMesh& mesh =
p.boundaryMesh().mesh();
148 (void)mesh.globalData().mergePoints
156 List<pointField> allPoints(Pstream::nProcs());
157 allPoints[proci] =
pointField(mesh.points(), uniquePointIDs);
158 Pstream::gatherList(allPoints, tag);
160 List<faceList> allFaces(Pstream::nProcs());
161 faceList& patchFaces = allFaces[proci];
162 patchFaces =
p.localFaces();
168 Pstream::gatherList(allFaces, tag);
170 if (Pstream::master())
174 ListListOps::combine<pointField>(allPoints, accessOp<pointField>())
178 osPoints << patchKey.c_str() << this->patch().name() << pts <<
endl;
182 ListListOps::combine<faceList>(allFaces, accessOp<faceList>())
186 osFaces<< patchKey.c_str() << this->patch().name() << fcs <<
endl;
194 return fileName(baseDir()/(lockName +
".lock"));
201 if (!master_ || !Pstream::master())
206 const fileName fName(lockFile());
227 if (!master_ || !Pstream::master())
246 const VolField<Type>& cvf =
247 static_cast<const VolField<Type>&
>(this->internalField());
249 const typename VolField<Type>::Boundary& bf =
252 forAll(coupledPatchIndices_, i)
257 refCast<const externalCoupledMixedFvPatchField<Type>>(bf[
patchi]);
271 const fileName fName(lockFile());
277 Info<<
type() <<
": beginning wait for lock file " << fName <<
endl;
282 if (Pstream::master())
284 if (totalTime > timeOut_)
287 <<
"Wait time exceeded time out time of " << timeOut_
304 sleep(waitInterval_);
305 totalTime += waitInterval_;
329 <<
"Unable to open data transfer file " << is.
name()
330 <<
" for patch " << this->patch().
name()
334 label offset = offsets_[this->patch().index()][Pstream::myProcNo()];
347 <<
"Unable to scan forward to appropriate read position for "
348 <<
"data transfer file " << is.
name()
349 <<
" for patch " << this->patch().
name()
371 forAll(this->patch(), facei)
375 is >> this->refValue()[facei]
376 >> this->refGrad()[facei]
377 >> this->valueFraction()[facei];
382 <<
"Insufficient data for patch "
383 << this->patch().name()
384 <<
" in file " << is.
name()
417 forAll(coupledPatchIndices_, i)
422 refCast<const externalCoupledMixedFvPatchField<Type>>(bf[
patchi]);
435 os <<
"# Values: magSf value snGrad" <<
endl;
451 commsDir_(
dict.lookup(
"commsDir")),
452 fName_(
dict.lookup(
"file")),
453 waitInterval_(
dict.lookupOrDefault(
"waitInterval", 1)),
454 timeOut_(
dict.lookupOrDefault(
"timeOut", 100*waitInterval_)),
455 calcFrequency_(
dict.lookupOrDefault(
"calcFrequency", 1)),
456 initByExternal_(
readBool(
dict.lookup(
"initByExternal"))),
457 log_(
dict.lookupOrDefault(
"log", false)),
461 coupledPatchIndices_()
463 if (
dict.found(
"value"))
482 if (!initByExternal_)
505 commsDir_(ptf.commsDir_),
507 waitInterval_(ptf.waitInterval_),
508 timeOut_(ptf.timeOut_),
509 calcFrequency_(ptf.calcFrequency_),
510 initByExternal_(ptf.initByExternal_),
512 master_(ptf.master_),
513 offsets_(ptf.offsets_),
514 initialised_(ptf.initialised_),
515 coupledPatchIndices_(ptf.coupledPatchIndices_)
528 commsDir_(ecmpf.commsDir_),
529 fName_(ecmpf.fName_),
530 waitInterval_(ecmpf.waitInterval_),
531 timeOut_(ecmpf.timeOut_),
532 calcFrequency_(ecmpf.calcFrequency_),
533 initByExternal_(ecmpf.initByExternal_),
535 master_(ecmpf.master_),
536 offsets_(ecmpf.offsets_),
537 initialised_(ecmpf.initialised_),
538 coupledPatchIndices_(ecmpf.coupledPatchIndices_)
565 const VolField<Type>& cvf =
566 static_cast<const VolField<Type>&
>(this->internalField());
568 VolField<Type>& vf =
const_cast<VolField<Type>&
>(cvf);
573 DynamicList<label> coupledPatchIDs(bf.size());
577 if (
isA<externalCoupledMixedFvPatchField<Type>>(bf[
patchi]))
579 coupledPatchIDs.append(
patchi);
583 coupledPatchIndices_.transfer(coupledPatchIDs);
592 forAll(coupledPatchIndices_, i)
596 externalCoupledMixedFvPatchField<Type>& pf =
597 refCast<externalCoupledMixedFvPatchField<Type>>(bf[
patchi]);
599 pf.setMaster(coupledPatchIndices_);
609 forAll(coupledPatchIndices_, i)
613 externalCoupledMixedFvPatchField<Type>& pf =
614 refCast<externalCoupledMixedFvPatchField<Type>>(bf[
patchi]);
616 pf.readData(transferFile);
622 setMaster(coupledPatchIndices_);
635 if (!initialised_ || this->db().time().
timeIndex() % calcFrequency_ == 0)
637 const fileName transferFile(baseDir()/fName_);
640 initialise(transferFile);
654 rm(transferFile +
".out");
658 readData(transferFile);
742 OFstream osPoints(baseDir()/
"patchPoints");
743 OFstream osFaces(baseDir()/
"patchFaces");
747 Info<<
"writing collated patch points to: " << osPoints.
name() <<
nl
748 <<
"writing collated patch faces to: " << osFaces.
name() <<
endl;
756 refCast<const externalCoupledMixedFvPatchField<Type>>
761 pf.writeGeometry(osPoints, osFaces);
774 writeEntry(os,
"waitInterval", waitInterval_);
776 writeEntry(os,
"calcFrequency", calcFrequency_);
777 writeEntry(os,
"initByExternal", initByExternal_);
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
#define forAll(list, i)
Loop across all elements in list.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
Pre-declare SubField and related Field type.
Generic GeometricBoundaryField class.
Generic GeometricField class.
GeometricBoundaryField< Type, PatchField, GeoMesh > Boundary
Type of the boundary field.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
const fileName & name() const
Return the name of the stream.
bool good() const
Return true if next operation might succeed.
ISstream & getLine(string &, const bool continuation=true)
Read line into a string.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(const label)
Reset size of List.
const fileName & name() const
Return the name of the stream.
virtual void flush()
Flush stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
commsTypes
Types of communications.
static bool master(const label communicator=0)
Am I the master process.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static bool & parRun()
Is this a parallel run?
static int & msgType()
Message tag of standard messages.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
A list of keyword definitions, which are a keyword followed by any number of values (e....
This boundary condition provides an interface to an external application. Values are transferred as p...
virtual ~externalCoupledMixedFvPatchField()
Destructor.
bool master() const
Return the master flag.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
virtual void writeHeader(OFstream &os) const
Write header to transfer file.
virtual void write(Ostream &) const
Write.
externalCoupledMixedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void writeData(const fileName &transferFile) const
Write data for external source - calls transferData.
void writeGeometry() const
Write the geometry to the comms dir.
virtual void transferData(OFstream &os) const
Transfer data for external source.
virtual void readData(const fileName &transferFile)
Read data from external source.
Abstract base class for field mapping.
A class for handling file names.
word name() const
Return file name (part beyond last /)
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
virtual void operator=(const UList< Type > &)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
This boundary condition provides a base class for 'mixed' type boundary conditions,...
virtual void write(Ostream &) const
Write.
virtual Field< Type > & refValue()
virtual scalarField & valueFraction()
virtual Field< Type > & refGrad()
A class for handling character strings derived from std::string.
string & expand(const bool allowEmpty=false)
Expand initial tildes and all occurrences of environment variables.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
tmp< SurfaceField< Type > > snGrad(const VolField< Type > &vf, const word &name)
void writeHeader(std::ostream &, const bool isBinary, const std::string &title)
Write header.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
errorManip< error > abort(error &err)
vectorField pointField
pointField is a vectorField.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
void evaluate(GeometricField< Type, PatchField, GeoMesh > &result, const Function1< Type > &func, const GeometricField< Type, PatchField, GeoMesh > &x)
void offset(label &lst, const label o)
unsigned int sleep(const unsigned int)
Sleep for the specified number of seconds.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
const bool writeData(readBool(pdfDictionary.lookup("writeData")))