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);
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);
174 map(tmapF, mapper, applyFlip);
196 if (IOobjectOption::isReadOptional(readOpt))
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
262 <<
"Expected keyword 'uniform' or 'nonuniform', found "
263 << firstToken.info() <<
nl
283 else if (readOpt != IOobjectOption::NO_READ)
285 const entry* eptr =
dict.findEntry(
key, keyType::LITERAL);
294 if (IOobjectOption::isReadRequired(readOpt))
297 <<
"Required entry '" <<
key <<
"' missing in dictionary "
298 <<
dict.relativeName() <<
nl
316 if (
f.size() != mapAddressing.
size())
318 f.resize(mapAddressing.
size());
325 const label mapI = mapAddressing[i];
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()
372 const labelList& localAddrs = mapAddressing[i];
373 const scalarList& localWeights = mapWeights[i];
379 f[i] += localWeights[j]*mapF[localAddrs[j]];
393 map(tmapF(), mapAddressing, mapWeights);
425 else if (!mapper.
direct())
434 this->transfer(newMapF);
465 map(tmapF(), mapper, applyFlip);
499 this->map(fCpy, mapper);
506 this->transfer(fCpy);
544 label mapI = mapAddressing[i];
561 rmap(tmapF(), mapAddressing);
580 f[mapAddressing[i]] += mapF[i]*mapWeights[i];
593 rmap(tmapF(), mapAddressing, mapWeights);
665 for (
auto& val : *
this)
677 for (
auto& val : *
this)
693 this->begin(
lower.size()),
710 this->begin(
upper.size()),
725 for (
auto& val : *
this)
739 template<
class VSForm>
745 vs[i] = this->operator[](start + i);
765 os.writeKeyword(keyword);
773 os << word(
"uniform") << token::SPACE << List<Type>::front();
777 os << word(
"nonuniform") << token::SPACE;
802 if (
this == &(rhs()))
812 template<
class Form,
class Cmpt, Foam::direction nCmpt>
819 #define COMPUTED_ASSIGNMENT(TYPE, op) \
821 template<class Type> \
822 void Foam::Field<Type>::operator op(const UList<TYPE>& f) \
824 TFOR_ALL_F_OP_F(Type, *this, op, TYPE, f) \
827 template<class Type> \
828 void Foam::Field<Type>::operator op(const tmp<Field<TYPE>>& tf) \
834 template<class Type> \
835 void Foam::Field<Type>::operator op(const TYPE& t) \
837 TFOR_ALL_F_OP_S(Type, *this, op, TYPE, t) \
845 #undef COMPUTED_ASSIGNMENT
853 os << static_cast<const List<Type>&>(
f);
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)
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 mapDistributeBase & distributeMap() const
Return the distribution map.
virtual const labelListList & addressing() const
Return the interpolation addressing.
virtual const labelUList & directAddressing() const
Return the direct addressing values.
virtual label size() const =0
The size of the mapper.
virtual bool distributed() const
Does the mapper have remote contributions?
virtual const scalarListList & weights() const
Return the interpolation weights.
Generic templated field type.
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< tensor >::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
readOption
Enumeration defining read preferences.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
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,...
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.
void size(const label n)
Older name for setAddressableSize.
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 class for managing temporary objects.
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)
rho clamp_range(rhoMin[i], rhoMax[i])
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
void assign(Field< Tout > &result, const Field< T1 > &a, const UnaryOp &op)
Populate a field as the result of a unary operation on an input.
const dimensionedScalar e
Elementary charge.
const dimensionedScalar c
Speed of light in a vacuum.
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
auto key(const Type &t) -> std::enable_if_t< std::is_enum_v< Type >, std::underlying_type_t< Type > >
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
errorManipArg< error, int > exit(error &err, const int errNo=1)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
bool notNull(const T *ptr) noexcept
True if ptr is not a pointer (of type T) to the nullObject.
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
errorManip< error > abort(error &err)
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
bool isNull(const T *ptr) noexcept
True if ptr is a pointer (of type T) to the nullObject.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
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.
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...
List< scalar > scalarList
List of scalar.
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.