45 uniformValuePtr_(nullptr),
82 phiName_(
dict.getOrDefault<
word>(
"phi",
"phi")),
87 if (outletDict.
empty())
89 FatalIOErrorInFunction(outletDict)
90 <<
"outlets dictionary is empty."
91 << exit(FatalIOError);
95 offsets_.setSize(outletDict.
size());
96 fractions_.setSize(outletDict.
size());
97 timeDelays_.setSize(outletDict.
size());
98 mapFields_.setSize(outletDict.
size());
99 mapTimes_.setSize(outletDict.
size());
102 for (
const entry& dEntry : outletDict)
104 const word& key = dEntry.keyword();
106 if (!dEntry.isDict())
109 <<
"Entry " << key <<
" is not a dictionary." <<
nl
115 outletNames_[outleti] = key;
153 mapFields_[outleti] =
154 subDict.getOrDefault<DynamicList<Type>>
161 subDict.getOrDefault<DynamicList<scalar>>
164 DynamicList<scalar>()
183 const outletMappedUniformInletFvPatchField<Type>& ptf,
185 const DimensionedField<Type, volMesh>& iF,
186 const fvPatchFieldMapper& mapper
189 fixedValueFvPatchField<Type>(ptf,
p, iF, mapper),
190 uniformValuePtr_(ptf.uniformValuePtr_.clone(
p.patch())),
191 outletNames_(ptf.outletNames_),
192 offsets_(ptf.offsets_),
193 fractions_(ptf.fractions_),
194 timeDelays_(ptf.timeDelays_),
195 mapFields_(ptf.mapFields_),
196 mapTimes_(ptf.mapTimes_),
197 phiName_(ptf.phiName_),
200 if (mapper.direct() && !mapper.hasUnmapped())
203 this->map(ptf, mapper);
208 this->extrapolateInternal();
221 uniformValuePtr_(ptf.uniformValuePtr_.clone(this->patch().patch())),
222 outletNames_(ptf.outletNames_),
223 offsets_(ptf.offsets_),
224 fractions_(ptf.fractions_),
225 timeDelays_(ptf.timeDelays_),
226 mapFields_(ptf.mapFields_),
227 mapTimes_(ptf.mapTimes_),
228 phiName_(ptf.phiName_),
242 uniformValuePtr_(ptf.uniformValuePtr_.clone(this->patch().patch())),
243 outletNames_(ptf.outletNames_),
244 offsets_(ptf.offsets_),
245 fractions_(ptf.fractions_),
246 timeDelays_(ptf.timeDelays_),
247 mapFields_(ptf.mapFields_),
248 mapTimes_(ptf.mapTimes_),
249 phiName_(ptf.phiName_),
264 if (uniformValuePtr_)
266 uniformValuePtr_->autoMap(m);
274 const fvPatchField<Type>& ptf,
283 if (uniformValuePtr_)
285 uniformValuePtr_->rmap(tiptf.uniformValuePtr_(), addr);
298 if (curTimeIndex_ != this->db().time().
timeIndex())
300 const scalar t = this->db().time().timeOutputValue();
306 this->internalField()
314 const word& outletName = outletNames_[i];
315 const label outletID =
316 p.patch().boundaryMesh().findPatchID(outletName);
321 <<
"Unable to find outlet patch " << outletName
328 scalar timeDelay = 0;
329 if (timeDelays_.set(i))
331 timeDelay =
max(timeDelays_[i].value(t), scalar(0));
333 mapTime.
append(t + timeDelay);
341 this->db().objectRegistry::template
342 lookupObject<surfaceScalarField>(phiName_);
344 const scalar sumOutletPhi =
gSum(outletPhi);
346 if (sumOutletPhi > SMALL)
351 offset = offsets_[i].value(t);
355 if (fractions_.set(i))
357 fraction = fractions_[i].value(t);
362 gSum(outletPhi*outletFld)/sumOutletPhi*fraction
368 const fvPatch& outlet =
p.boundaryMesh()[outletID];
385 if (!mapTime.empty())
387 if (t >= mapTime.first())
393 while (!mapTime.empty() && t >= mapTime[i])
404 if (uniformValuePtr_)
406 this->
operator==(inletFld + uniformValuePtr_->value(t));
414 curTimeIndex_ = this->db().time().timeIndex();
427 if (uniformValuePtr_)
429 uniformValuePtr_->writeData(
os);
431 os.beginBlock(
"outlets");
434 os.beginBlock(outletNames_[i]);
437 offsets_[i].writeData(
os);
439 if (fractions_.set(i))
441 fractions_[i].writeData(
os);
443 if (timeDelays_.set(i))
445 timeDelays_[i].writeData(
os);
447 if (!mapFields_.empty())
449 mapFields_[i].writeEntry(
"mapField",
os);
451 if (!mapTimes_.empty())
453 mapTimes_[i].writeEntry(
"mapTime",
os);
for(const label curEdgei :curPointEdges)
bool empty() const noexcept
True if the list is empty.
label size() const noexcept
The number of elements in list.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
void append(const T &val)
Append an element at the end of the list.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
T remove()
Remove and return the last element. Fatal on an empty list.
void append(const T &val)
Copy append an element to the end of this list.
virtual bool direct() const =0
Is it a direct (non-interpolating) mapper?
virtual bool hasUnmapped() const =0
Any unmapped values?
static autoPtr< Function1< Type > > NewIfPresent(const word &entryName, const dictionary &dict, const word &redirectType, const objectRegistry *obrPtr=nullptr)
An optional selector, with fallback redirection.
Generic GeometricField class.
void setSize(label n)
Alias for resize().
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual Ostream & endBlock()
Write end block group.
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
T & first()
Access first element of the list, position [0].
bool empty() const noexcept
True if List is empty (ie, size() is zero).
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
A keyword and a list of tokens is an 'entry'.
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
fixedValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
const objectRegistry & db() const
The associated objectRegistry.
const fvPatch & patch() const noexcept
Return the patch.
bool updated() const noexcept
True if the boundary condition has already been updated.
A FieldMapper for finite-volume patch fields.
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.
virtual void write(Ostream &) const
Write.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
const DimensionedField< Type, volMesh > & internalField() const noexcept
Return const-reference to the dimensioned internal field.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
bool readValueEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "value" entry into *this.
void extrapolateInternal()
Assign the patch field from the internal field.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
const scalarField & magSf() const
Return face area magnitudes, like the fvMesh::magSf() method.
A class for handling words, derived from Foam::string.
static const word null
An empty word.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
Interpolates y values from one curve to another with a different x distribution.
const std::string patch
OpenFOAM patch number as a std::string.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Type gSum(const FieldField< Field, Type > &f)
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< Type > interpolateXY(const scalarField &xNew, const scalarField &xOld, const Field< Type > &yOld)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
errorManip< error > abort(error &err)
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).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.