36Type Foam::mappedPatchFieldBase<Type>::getAverage
44 return dict.get<Type>(
"average");
60 const word& fieldName,
71 const label proci = procIDs[ranki];
82 mapper_.sendPath(proci)
90 Pout<<
"*** STORING :"
91 <<
" field:" << fieldName
93 <<
" as:" << subObr.objectPath() <<
endl;
106 const bool allowUnset,
107 const objectRegistry& obr,
111 const labelListList& procToMap,
112 const word& fieldName,
116 const auto& procIDs = UPstream::procID(myComm);
123 const label proci = procIDs[ranki];
127 auto& subObr =
const_cast<objectRegistry&
>
129 mappedPatchBase::subRegistry
132 mapper_.receivePath(proci)
138 const IOField<T>* subFldPtr = subObr.getObjectPtr<IOField<T>>
144 if (subFldPtr->size() != map.size())
161 Pout<<
"*** RETRIEVED :"
162 <<
" field:" << fieldName
164 <<
" from:" << subObr.objectPath() <<
endl;
173 <<
" field:" << fieldName
174 <<
" in:" << subObr.objectPath() <<
endl;
189 (void)subObr.lookupObject<IOField<T>>(fieldName);
206 const word& fieldName,
215 for (label domain = 0; domain < nProcs; domain++)
217 const labelList& constructMap = map[domain];
218 if (constructMap.
size())
236 <<
" field:" << fieldName <<
" values:"
239 <<
" constructMap:" <<
flatOutput(constructMap)
240 <<
" as:" << subObr.objectPath() <<
endl;
253 const word& fieldName,
255 const labelListList& subMap,
256 const label constructSize,
257 const labelListList& constructMap,
258 const labelListList& address,
259 const scalarListList& weights,
265 patchField_.internalField().time(),
266 patchField_.patch().boundaryMesh().mesh().name(),
267 patchField_.patch().name(),
274 Field<T> work(constructSize);
275 const bool ok = retrieveField
278 patchField_.internalField().time(),
279 mapper_.sampleRegion(),
280 mapper_.samplePatch(),
291 fld.setSize(address.size());
294 const plusEqOp<T> cop;
295 const multiplyWeightedOp<T, plusEqOp<T>> mop(cop);
304 mop(
fld[facei], facei, work[slots[i]], w[i]);
324 const word& fieldName,
325 const bool setAverage,
327 const word& interpolationScheme
371 <<
"Mapping using the database only supported for "
373 << mappedPatchBase::sampleModeNames_
375 mappedPatchBase::NEARESTPATCHFACE
378 << mappedPatchBase::sampleModeNames_
380 mappedPatchBase::NEARESTPATCHFACEAMI
387 dict.readEntry(
"interpolationScheme", interpolationScheme_);
408 if (mapper_.mode() == mappedPatchBase::NEARESTPATCHFACE)
413 patchField_.internalField().time(),
415 mapper_.sampleRegion(),
417 mapper_.samplePatch(),
418 mapper_.map().constructMap(),
419 patchField_.internalField().name(),
436 const mappedPatchBase& mapper,
437 const fvPatchField<Type>& patchField
441 patchField_(patchField),
442 fieldName_(patchField_.internalField().
name()),
455 mapper_(mapper.mapper_),
456 patchField_(mapper.patchField_),
457 fieldName_(mapper.fieldName_),
473 patchField_(patchField),
474 fieldName_(base.fieldName_),
475 setAverage_(base.setAverage_),
476 average_(base.average_),
477 interpolationScheme_(base.interpolationScheme_)
492 if (fieldName ==
patchField_.internalField().name())
496 dynamic_cast<const fieldType&
>
504 return thisMesh.template lookupObject<fieldType>(fieldName);
509 return nbrMesh.template lookupObject<fieldType>(fieldName);
525 const word& fieldName,
529 if (mapper_.sampleDatabase())
531 const label myComm = mapper_.getCommunicator();
538 patchField_.internalField().time(),
539 patchField_.patch().boundaryMesh().mesh().name(),
540 patchField_.patch().name(),
542 mapper_.map().subMap(),
547 fld.setSize(mapper_.map().constructSize());
551 patchField_.internalField().time(),
552 mapper_.sampleRegion(),
553 mapper_.samplePatch(),
555 mapper_.map().constructMap(),
569 if (mapper_.masterWorld())
573 storeAndRetrieveField
577 AMI.srcMap().subMap(),
578 AMI.tgtMap().constructSize(),
579 AMI.tgtMap().constructMap(),
589 storeAndRetrieveField
593 AMI.tgtMap().subMap(),
594 AMI.srcMap().constructSize(),
595 AMI.srcMap().constructMap(),
605 mapper_.distribute(
fld);
618 typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
624 const fvMesh& thisMesh = patchField_.patch().boundaryMesh().mesh();
627 auto tnewValues = tmp<Field<Type>>
::New();
628 auto& newValues = tnewValues.ref();
630 switch (mapper_.mode())
634 const fieldType&
fld = sampleField();
635 const mapDistribute& distMap = mapper_.map();
637 if (interpolationScheme_ != interpolationCell<Type>::typeName)
639 if (!mapper_.sameWorld() || mapper_.sampleDatabase())
642 <<
"Interpolating cell values from different world"
643 <<
" or database currently not supported"
647 const fvMesh& nbrMesh =
653 distMap.reverseDistribute
667 interpolationScheme_,
671 const auto& interp = *interpolator;
673 newValues.setSize(
samples.size(), pTraits<Type>::max);
678 newValues[celli] = interp.interpolate
691 distribute(fieldName_, newValues);
698 if (mapper_.sameWorld())
702 const fieldType&
fld = sampleField();
704 const label nbrPatchID =
705 nbrMesh.boundaryMesh().findPatchID(mapper_.samplePatch());
710 <<
"Unable to find sample patch " << mapper_.samplePatch()
711 <<
" in region " << mapper_.sampleRegion()
712 <<
" for patch " << patchField_.patch().name() <<
nl
716 const auto& nbrField =
fld;
718 newValues = nbrField.boundaryField()[nbrPatchID];
724 newValues = patchField_;
726 distribute(fieldName_, newValues);
733 if (mapper_.sameWorld())
737 const fieldType&
fld = sampleField();
739 allValues.setSize(nbrMesh.nFaces(),
Zero);
741 const auto& nbrField =
fld;
745 label faceStart = pf.patch().start();
749 allValues[faceStart++] = pf[facei];
757 allValues.setSize(thisMesh.nFaces(),
Zero);
759 const fieldType& thisFld =
dynamic_cast<const fieldType&
>
761 patchField_.internalField()
766 label faceStart = pf.patch().start();
770 allValues[faceStart++] = pf[facei];
775 distribute(fieldName_, allValues);
776 newValues.transfer(allValues);
783 <<
"Unknown sampling mode: " << mapper_.mode() <<
nl
793 if (
mag(averagePsi) > 0.5*
mag(average_))
795 newValues *=
mag(average_)/
mag(averagePsi);
799 newValues += (average_ - averagePsi);
824 auto& nbrIntFld = tnbrIntFld.ref();
829 const label nbrPatchID =
mapper_.samplePolyPatch().index();
831 nbrIntFld = nbrField.boundaryField()[nbrPatchID].patchInternalField();
858 auto& nbrKDelta = tnbrKDelta.ref();
860 if (mapper_.sameWorld())
864 const label nbrPatchID = mapper_.samplePolyPatch().index();
865 const auto& nbrPatch = nbrMesh.boundary()[nbrPatchID];
866 nbrKDelta = nbrPatch.deltaCoeffs();
872 nbrKDelta = patchField_.patch().deltaCoeffs();
880 distribute(fieldName_ +
"_deltaCoeffs", nbrKDelta);
891 const word& fieldName,
896 thisWeights =
new scalarField(patchField_.patch().deltaCoeffs());
897 if (!fieldName.empty())
900 patchField_.patch().template lookupPatchField<volScalarField>
903 ).patchInternalField();
909 if (mapper_.sameWorld())
913 const label nbrPatchID = mapper_.samplePolyPatch().index();
914 const auto& nbrPatch = nbrMesh.boundary()[nbrPatchID];
916 nbrWeights =
new scalarField(nbrPatch.deltaCoeffs());
918 if (!fieldName.empty())
921 const auto& nbrWeightField =
922 nbrMesh.template lookupObject<volScalarField>(fieldName);
924 nbrWeightField.boundaryField()[nbrPatchID].patchInternalField();
954 <<
"Incorrect patch type " <<
p.patch().type()
955 <<
" for patch " <<
p.patch().name()
956 <<
" of field " << iF.
name()
958 <<
"Type should be a mappedPatch"
969 const word& fieldName,
973 if (mapper_.sampleDatabase())
981 patchField_.internalField().time(),
982 mapper_.sampleRegion(),
983 mapper_.samplePatch(),
984 mapper_.map().constructMap(),
1000 patchField_.internalField().
name(),
1012 os.
writeEntry(
"interpolationScheme", interpolationScheme_);
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
const mapDistribute & srcMap() const
Source map - valid only if singlePatchProc = -1 This gets source data into a form to be consumed by t...
const mapDistribute & tgtMap() const
Target map - valid only if singlePatchProc=-1. This gets target data into a form to be consumed by sr...
const scalarListList & tgtWeights() const
Return const access to target patch weights.
const labelListList & srcAddress() const
Return const access to source patch addressing.
const scalarListList & srcWeights() const
Return const access to source patch weights.
const labelListList & tgtAddress() const
Return const access to target patch addressing.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Generic GeometricField class.
A primitive field of type <T> with automated input and output.
const word & name() const noexcept
Return the object name.
fileName objectPath() const
The complete path + object name.
void setSize(label n)
Alias for resize().
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
A List with indirect addressing. Like IndirectList but does not store addressing.
void size(const label n)
Older name for setAddressableSize.
static List< int > & procID(int communicator)
The list of ranks within a given communicator.
static int & msgType() noexcept
Message tag of standard messages.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static int incrMsgType(int val=1) noexcept
Increment the message tag for standard messages.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Mesh data needed to do the Finite Volume discretisation.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Uses the cell value for any location within the cell.
static autoPtr< interpolation< Type > > New(const word &interpolationType, const GeometricField< Type, fvPatchField, volMesh > &psi)
Return a reference to the specified interpolation scheme.
const labelListList & constructMap() const noexcept
From subsetted data to new reconstructed data.
const labelListList & subMap() const noexcept
From subsetted data back to original data.
label constructSize() const noexcept
Constructed data size.
Class containing processor-to-processor mapping information.
void reverseDistribute(const label constructSize, List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Reverse distribute data using default commsType.
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
static FOAM_NO_DANGLING_REFERENCE const objectRegistry & subRegistry(const objectRegistry &obr, const wordList &names, const label index)
Lookup (sub)objectRegistry by following names of sub registries. Creates non-existing intermediate on...
@ NEARESTCELL
nearest cell containing sample
@ NEARESTPATCHFACE
nearest face on selected patch
@ NEARESTPATCHFACEAMI
nearest patch face + AMI interpolation
@ NEARESTFACE
nearest face
bool sampleDatabase() const noexcept
sampleMode mode() const noexcept
What to sample.
static void storeField(objectRegistry &obr, const word &fieldName, const Field< Type > &values)
Store an IOField on the objectRegistry relative to obr.
Functionality for sampling fields using mappedPatchBase. Every call to mappedField() returns a sample...
void storeField(const objectRegistry &obr, const word ®ion, const word &patch, const label myComm, const labelListList &procToMap, const word &fieldName, const Field< T > &fld) const
Store elements of field onto (sub) registry.
const mappedPatchBase & mapper_
Mapping engine.
void initRetrieveField(const objectRegistry &obr, const word ®ion, const word &patch, const labelListList &map, const word &fieldName, const Field< T > &fld) const
Construct field from registered elements.
virtual tmp< Field< Type > > mappedField() const
Map sampleField onto *this patch.
const GeometricField< T, fvPatchField, volMesh > & sampleField(const word &fieldName) const
Field to sample. Either on my or nbr mesh.
virtual void write(Ostream &os) const
Write.
static const mappedPatchBase & mapper(const fvPatch &p, const DimensionedField< Type, volMesh > &iF)
Check that patch is of correct type.
virtual tmp< scalarField > mappedWeightField() const
Map optional weightField onto *this patch. Default is deltaCoeffs.
virtual tmp< Field< Type > > mappedInternalField() const
Map internal of sampleField onto *this patch.
const GeometricField< Type, fvPatchField, volMesh > & sampleField() const
Field to sample. Either on my or nbr mesh.
mappedPatchFieldBase(const mappedPatchBase &mapper, const fvPatchField< Type > &patchField, const word &fieldName, const bool setAverage, const Type average, const word &interpolationScheme)
Construct from components.
const fvPatchField< Type > & patchField_
Underlying patch field.
word interpolationScheme_
bool retrieveField(const bool allowUnset, const objectRegistry &obr, const word ®ion, const word &patch, const label myComm, const labelListList &procToMap, const word &fieldName, Field< T > &fld) const
Construct field from registered elements.
void distribute(const word &fieldName, Field< T > &newValues) const
Wrapper for mapDistribute::distribute that knows about dabase mapping.
bool storeAndRetrieveField(const word &fieldName, const label myComm, const labelListList &subMap, const label constructSize, const labelListList &constructMap, const labelListList &address, const scalarListList &weights, Field< T > &fld) const
Helper : storeField and retrieveField and interpolate. Leaves fld.
Registry of regIOobjects.
A traits class, which is primarily used for primitives and vector-space.
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
label nCells() const noexcept
Number of mesh cells.
label nFaces() const noexcept
Number of mesh faces.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
const std::string patch
OpenFOAM patch number as a std::string.
List< scalarList > scalarListList
List of scalarList.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
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.
List< labelList > labelListList
List of labelList.
Type gWeightedAverage(const UList< scalar > &weights, const UList< Type > &fld, const label comm)
The global weighted average of a field, using the mag() of the weights.
List< label > labelList
A List of labels.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
AMIInterpolation AMIPatchToPatchInterpolation
Patch-to-patch interpolation == Foam::AMIInterpolation.
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< scalar > scalarList
List of scalar.
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1, const label comm)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
scalarField samples(nIntervals, Zero)