86 const word& nbrPatchName =
pp.neighbPatchName();
88 const Switch distributed =
pp.AMI().distributed();
91 const auto srcWeightLimits =
gMinMax(srcWeightsSum);
92 const auto srcWeightAvg =
gAverage(srcWeightsSum);
98 for (
const labelList& srcFace : srcAddress)
100 const label
n = srcFace.size();
107 reduce(srcNbrLimits, sumOp<labelMinMax>());
109 label count = srcAddress.size();
111 srcNbrAvg /= (count + ROOTVSMALL);
115 const auto tgtWeightLimits =
gMinMax(tgtWeightsSum);
116 const auto tgtWeightAvg =
gAverage(tgtWeightsSum);
122 for (
const labelList& tgtFace : tgtAddress)
124 const label
n = tgtFace.size();
131 reduce(tgtNbrLimits, sumOp<labelMinMax>());
133 label
count = tgtAddress.size();
135 tgtNbrAvg /= (
count + ROOTVSMALL);
139 << mesh_.time().timeName() <<
tab
141 << nbrPatchName <<
tab;
146 file() << distributed <<
tab;
150 << srcWeightLimits.min() <<
tab
151 << srcWeightLimits.max() <<
tab
152 << srcWeightAvg <<
tab
153 << srcNbrLimits.min() <<
tab
154 << srcNbrLimits.max() <<
tab
156 << tgtWeightLimits.min() <<
tab
157 << tgtWeightLimits.max() <<
tab
158 << tgtWeightAvg <<
tab
159 << tgtNbrLimits.min() <<
tab
160 << tgtNbrLimits.max() <<
tab
164 Log <<
" Patches: " <<
nl
165 <<
" Source: " <<
pp.name() <<
nl
166 <<
" Target: " << nbrPatchName <<
nl;
170 Log <<
" Parallel distributed: " << distributed <<
nl;
178 <<
" | " <<
setw(w) << nbrPatchName <<
" | " <<
nl
179 <<
" min(weight) | " <<
setw(w) << srcWeightLimits.min()
180 <<
" | " <<
setw(w) << tgtWeightLimits.min() <<
" | " <<
nl
181 <<
" max(weight) | " <<
setw(w) << srcWeightLimits.max()
182 <<
" | " <<
setw(w) << tgtWeightLimits.max() <<
" | " <<
nl
183 <<
" ave(weight) | " <<
setw(w) << srcWeightAvg
184 <<
" | " <<
setw(w) << tgtWeightAvg <<
" | " <<
nl
185 <<
" min(address) | " <<
setw(w) << srcNbrLimits.min()
186 <<
" | " <<
setw(w) << tgtNbrLimits.min() <<
" | " <<
nl
187 <<
" max(address) | " <<
setw(w) << srcNbrLimits.max()
188 <<
" | " <<
setw(w) << tgtNbrLimits.max() <<
" | " <<
nl
189 <<
" ave(address) | " <<
setw(w) << srcNbrAvg
190 <<
" | " <<
setw(w) << tgtNbrAvg <<
" | " <<
nl
193 setResult(
pp.name() +
":src",
pp.name());
194 setResult(
pp.name() +
":tgt", nbrPatchName);
195 setResult(
pp.name() +
":src:min(weight)", srcWeightLimits.min());
196 setResult(
pp.name() +
":src:max(weight)", srcWeightLimits.max());
197 setResult(
pp.name() +
":src:ave(weight)", srcWeightAvg);
198 setResult(
pp.name() +
":src:min(address)", srcNbrLimits.min());
199 setResult(
pp.name() +
":src:max(address)", srcNbrLimits.max());
200 setResult(
pp.name() +
":src:ave(address)", srcNbrAvg);
201 setResult(
pp.name() +
":tgt:min(weight)", tgtWeightLimits.min());
202 setResult(
pp.name() +
":tgt:max(weight)", tgtWeightLimits.max());
204 setResult(
pp.name() +
":tgt:min(address)", tgtNbrLimits.min());
205 setResult(
pp.name() +
":tgt:max(address)", tgtNbrLimits.max());
206 setResult(
pp.name() +
":tgt:ave(address)", tgtNbrAvg);
232 uniqueMeshPointLabels,
241 scalarField mergedWeights = globalFaces().gather(weightSum);
250 mergedMask = globalFaces().gather(
pp.mask());
255 instant inst(mesh_.time().value(), mesh_.time().timeName());
261 (baseTimeDir()/cpp.
name() +
"_" + side),
269 writer.beginCellData(1 + (isACMI ? 1 : 0));
270 writer.write(
"weightsSum", mergedWeights);
274 writer.write(
"mask", mergedMask);
282 const cyclicAMIPolyPatch& cpp
287 writeWeightField(cpp, cpp.AMI().srcWeightsSum(),
"src");
324 if (amicpp && amicpp->owner())
332 writeFileHeader(file());
334 writeFields_ =
dict.get<
bool>(
"writeFields");
354 for (
const label patchi : patchIDs_)
363 writeWeightFields(cpp);
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edgesCentres")))
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const polyBoundaryMesh & pbm
const scalarField & srcWeightsSum() const
Return const access to normalisation factor of source patch weights (i.e. the sum before normalisatio...
const scalarField & tgtWeightsSum() const
Return const access to normalisation factor of target patch weights (i.e. the sum before normalisatio...
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
static unsigned int defaultPrecision() noexcept
Return the default precision.
const T & max() const noexcept
The max value.
const T & min() const noexcept
The min value.
MinMax< T > & add(const MinMax &other)
Extend the range to include the other min/max range.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
const Map< label > & meshPointMap() const
Mesh point map.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
void size(const label n)
Older name for setAddressableSize.
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static bool & parRun() noexcept
Test if this a parallel run.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Cyclic patch for Arbitrarily Coupled Mesh Interface (ACMI).
Cyclic patch for Arbitrary Mesh Interface (AMI).
virtual bool owner() const
Does this side own the patch?
const AMIPatchToPatchInterpolation & AMI() const
Return a reference to the AMI interpolator.
virtual const cyclicAMIPolyPatch & neighbPatch() const
Return a reference to the neighbour patch.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Abstract base-class for Time/database function objects.
virtual bool read(const dictionary &dict)
Read and set the function object if its data have changed.
Computes the min/max/average weights of arbitrary mesh interface (AMI) patches, and optionally report...
void writeWeightFields(const cyclicAMIPolyPatch &cpp) const
Write weight fields if writeFields=true.
void writeWeightField(const cyclicAMIPolyPatch &cpp, const scalarField &weightSum, const word &side) const
Write weight field.
virtual void reportPatch(const cyclicAMIPolyPatch &pp)
Helper function to report patch information.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
AMIWeights(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
bool writeFields_
Flag to write AMI fields (as VTK files).
virtual void writeFileHeader(Ostream &os)
Output file header information.
virtual bool execute()
Execute the function-object operations (no-op).
virtual bool write()
Write the function-object results.
labelList patchIDs_
List of AMI patch IDs.
const fvMesh & mesh_
Reference to the fvMesh.
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
void setResult(const word &entryName, const Type &value)
Add result.
virtual void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.
writeFile(const objectRegistry &obr, const fileName &prefix, const word &name="undefined", const bool writeToFile=true, const string &ext=".dat")
Construct from objectRegistry, prefix, fileName.
virtual void writeHeader(Ostream &os, const string &str) const
Write a commented header to stream.
virtual bool read(const dictionary &dict)
Read.
virtual OFstream & file()
Return access to the file (if only 1).
virtual void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
fileName baseTimeDir() const
Return the base directory for the current time value.
Calculates points shared by more than two processor patches or cyclic patches.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
const word & name() const noexcept
The patch name.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
A patch is a list of labels that address the faces in the global face list.
Write faces/points (optionally with fields) as a vtp file or a legacy vtk file.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
OBJstream os(runTime.globalPath()/outputName)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Type gAverage(const FieldField< Field, Type > &f, const label comm)
The global arithmetic average of a FieldField.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
List< labelList > labelListList
List of labelList.
bool read(const char *buf, int32_t &val)
Same as readInt32.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
MinMax< label > labelMinMax
A label min/max range.
List< face > faceList
List of faces.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Omanip< int > setw(const int i)
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.
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
void sumReduce(T &value, CountType &count, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) the sum of value and counter (eg, for averaging).
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
vectorField pointField
pointField is a vectorField.
constexpr char nl
The newline '\n' character (0x0a).
constexpr char tab
The tab '\t' character(0x09).
#define forAll(list, i)
Loop across all elements in list.