43 List<Type>(mapAddressing.
size())
45 map(mapF, mapAddressing);
56 List<Type>(mapAddressing.
size())
58 map(tmapF, mapAddressing);
70 List<Type>(mapAddressing.
size())
72 map(mapF, mapAddressing, mapWeights);
84 List<Type>(mapAddressing.
size())
86 map(tmapF, mapAddressing, mapWeights);
100 map(mapF, mapper, applyFlip);
109 const Type& defaultValue,
113 List<Type>(mapper.
size(), defaultValue)
115 map(mapF, mapper, applyFlip);
128 List<Type>(defaultValues)
130 map(mapF, mapper, applyFlip);
144 map(tmapF, mapper, applyFlip);
153 const Type& defaultValue,
157 List<Type>(mapper.
size(), defaultValue)
159 map(tmapF, mapper, applyFlip);
172 List<Type>(defaultValues)
174 map(tmapF, mapper, applyFlip);
204 if (len > 0) this->
resize(len);
217 ITstream& is =
e.stream();
220 token firstToken(is);
222 if (firstToken.isWord(
"uniform"))
227 this->resize_nocopy(len);
229 operator=(pTraits<Type>(is));
231 else if (firstToken.isWord(
"nonuniform"))
233 is >>
static_cast<List<Type>&
>(*this);
234 const label lenRead = this->size();
237 if (len >= 0 && len != lenRead)
239 if (len < lenRead && FieldBase::allowConstructFromLargerSize)
246 <<
"Sizes do not match. Truncating " << lenRead
247 <<
" entries to " << len <<
endl;
253 <<
"Size " << lenRead
254 <<
" is not equal to the expected length " << len
255 <<
exit(FatalIOError);
262 <<
"Expected keyword 'uniform' or 'nonuniform', found "
263 << firstToken.info() <<
nl
276 IOobjectOption::readOption readOpt
283 else if (readOpt != IOobjectOption::NO_READ)
285 const entry* eptr =
dict.findEntry(key, keyType::LITERAL);
289 Field<Type>::assign(*eptr, len);
294 if (IOobjectOption::isReadRequired(readOpt))
297 <<
"Required entry '" <<
key <<
"' missing in dictionary "
298 <<
dict.relativeName() <<
nl
299 <<
exit(FatalIOError);
310 const UList<Type>& mapF,
311 const labelUList& mapAddressing
314 Field<Type>&
f = *
this;
316 if (
f.size() != mapAddressing.size())
318 f.resize(mapAddressing.size());
325 const label mapI = mapAddressing[i];
339 const tmp<Field<Type>>& tmapF,
340 const labelUList& mapAddressing
343 map(tmapF(), mapAddressing);
358 if (
f.size() != mapAddressing.
size())
360 f.resize(mapAddressing.
size());
363 if (mapWeights.
size() != mapAddressing.
size())
366 << mapWeights.
size() <<
" map size: " << mapAddressing.
size()
367 << abort(FatalError);
372 const labelList& localAddrs = mapAddressing[i];
373 const scalarList& localWeights = mapWeights[i];
379 f[i] += localWeights[j]*mapF[localAddrs[j]];
388 const tmp<Field<Type>>& tmapF,
389 const labelListList& mapAddressing,
390 const scalarListList& mapWeights
393 map(tmapF(), mapAddressing, mapWeights);
425 else if (!mapper.
direct())
434 this->transfer(newMapF);
460 const tmp<Field<Type>>& tmapF,
461 const FieldMapper& mapper,
465 map(tmapF(), mapper, applyFlip);
499 this->
map(fCpy, mapper);
544 label mapI = mapAddressing[i];
557 const tmp<Field<Type>>& tmapF,
558 const labelUList& mapAddressing
561 rmap(tmapF(), mapAddressing);
580 f[mapAddressing[i]] += mapF[i]*mapWeights[i];
593 rmap(tmapF(), mapAddressing, mapWeights);
665 for (
auto& val : *
this)
667 val =
max(val, lower);
677 for (
auto& val : *
this)
679 val =
min(val, upper);
693 this->begin(lower.size()),
710 this->begin(upper.size()),
725 for (
auto& val : *
this)
727 val =
min(
max(val, lower), upper);
739template<
class VSForm>
743 for (
direction i=0; i<VSForm::nComponents; i++)
765 os.writeKeyword(keyword);
771 if (is_contiguous_v<Type> && List<Type>::uniform())
773 os << word(
"uniform") << token::SPACE << List<Type>::front();
777 os << word(
"nonuniform") << token::SPACE;
778 List<Type>::writeEntry(
os);
802 if (
this == &(rhs()))
812template<
class Form,
class Cmpt, Foam::direction nCmpt>
819#define COMPUTED_ASSIGNMENT(TYPE, op) \
821template<class Type> \
822void Foam::Field<Type>::operator op(const UList<TYPE>& f) \
824 TFOR_ALL_F_OP_F(Type, *this, op, TYPE, f) \
827template<class Type> \
828void Foam::Field<Type>::operator op(const tmp<Field<TYPE>>& tf) \
834template<class Type> \
835void Foam::Field<Type>::operator op(const TYPE& t) \
837 TFOR_ALL_F_OP_S(Type, *this, op, TYPE, t) \
845#undef COMPUTED_ASSIGNMENT
#define COMPUTED_ASSIGNMENT(TYPE, op)
Declaration macros for Field<Type> algebra.
#define TFOR_ALL_F_OP_OP_F(typeF1, f1, OP1, OP2, typeF2, f2)
#define TFOR_ALL_F_OP_S(typeF, f, OP, typeS, s)
#define TFOR_ALL_F_OP_FUNC_S_S(typeF1, f1, OP, FUNC, typeS1, s1, typeS2, s2)
#define TFOR_ALL_F_OP_FUNC_S_F(typeF1, f1, OP, FUNC, typeS, s, typeF2, f2)
#define COMPUTED_ASSIGNMENT(TYPE, op)
static bool allowConstructFromLargerSize
Permit read construct from a larger size.
Abstract base class to hold the Field mapping addressing and weights.
virtual bool direct() const =0
Is it a direct (non-interpolating) mapper?
virtual const labelUList & directAddressing() const
Return the direct addressing values.
virtual const scalarListList & weights() const
Return the interpolation weights.
virtual label size() const =0
The size of the mapper.
virtual bool distributed() const
Does the mapper have remote contributions?
virtual const labelListList & addressing() const
Return the interpolation addressing.
virtual const mapDistributeBase & distributeMap() const
Return the distribution map.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
static autoPtr< Field< Type > > New(Istream &is)
Return a pointer to a new Field created on freestore.
tmp< Field< Type > > T() const
Return the field transpose (only defined for second rank tensors).
void operator=(const Field< Type > &)
Copy assignment.
void clamp_range(const Type &lower, const Type &upper)
Clamp field values (in-place) to the specified range.
void autoMap(const FieldMapper &map, const bool applyFlip=true)
Map from self.
void clamp_min(const Type &lower)
Impose lower (floor) clamp on the field values (in-place).
pTraits< Type >::cmptType cmptType
Component type.
void writeEntry(const word &keyword, Ostream &os) const
Write the field as a dictionary entry.
void replace(const direction, const UList< cmptType > &)
Replace a component field of the field.
constexpr Field() noexcept
Default construct.
void assign(const entry &e, const label len)
Assign from a primitive dictionary entry with the following behaviour:
void negate()
Inplace negate this field (negative).
void clamp_max(const Type &upper)
Impose upper (ceiling) clamp on the field values (in-place).
void map(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 map from the given field
void normalise()
Inplace normalise this field. Generally a no-op except for vector fields.
void rmap(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 reverse-map from the given field
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
VSForm block(const label start) const
static bool isReadOptional(readOption opt) noexcept
True if (LAZY_READ) bits are set [same as READ_IF_PRESENT].
static bool isReadRequired(readOption opt) noexcept
True if (MUST_READ | READ_MODIFIED) bits are set.
readOption
Enumeration defining read preferences.
@ NO_READ
Nothing to be read.
An input stream of tokens.
void transfer(List< Type > &list)
void resize_nocopy(const label len)
void operator=(const UList< T > &list)
Assignment to UList operator. Takes linear time.
A min/max value pair with additional methods. In addition to conveniently storing values,...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
iterator begin() noexcept
bool uniform() const
True if all entries have identical values, and list is non-empty.
void writeEntry(Ostream &os) const
Write the UList with its compound type.
TypeGrad & operator[](const label i)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A keyword and a list of tokens is an 'entry'.
Class containing processor-to-processor mapping information.
static void distribute(const UPstream::commsTypes commsType, const UList< labelPair > &schedule, const label constructSize, const labelListList &subMap, const bool subHasFlip, const labelListList &constructMap, const bool constructHasFlip, List< T > &field, const T &nullValue, const CombineOp &cop, const NegateOp &negOp, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Distribute combine data with specified combine operation and negate operator (for flips).
A traits class, which is primarily used for primitives and vector-space.
A class for managing temporary objects.
A token holds an item read from Istream.
bool isWord() const noexcept
Token is word-variant (WORD, DIRECTIVE).
InfoProxy< token > info() const noexcept
Return info proxy, for printing token information to a stream.
A class for handling words, derived from Foam::string.
patchWriters resize(patchIds.size())
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
constexpr auto key(const Type &t) noexcept
Helper function to return the enum value.
List< scalarList > scalarListList
List of scalarList.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
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.
List< label > labelList
A List of labels.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Ostream & endl(Ostream &os)
Add newline and flush stream.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
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...
constexpr bool is_contiguous_v
The is_contiguous value of Type (after stripping of qualifiers).
bool notNull(const T *ptr) noexcept
True if ptr is not a pointer (of type T) to the nullObject.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
List< scalar > scalarList
List of scalar.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
bool isNull(const T *ptr) noexcept
True if ptr is a pointer (of type T) to the nullObject.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
A functor that returns its argument unchanged (cf. C++20 std::identity) Should never be specialized.