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);
98 List<Type>(mapper.size())
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);
142 List<Type>(mapper.size())
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 274 const dictionary&
dict,
276 IOobjectOption::readOption readOpt
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];
339 const tmp<Field<Type>>& tmapF,
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]];
388 const tmp<Field<Type>>& tmapF,
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);
506 this->transfer(fCpy);
522 Field<Type> fCpy(*
this);
536 const UList<Type>& mapF,
540 Field<Type>&
f = *
this;
544 label mapI = mapAddressing[i];
557 const tmp<Field<Type>>& tmapF,
561 rmap(tmapF(), mapAddressing);
580 f[mapAddressing[i]] += mapF[i]*mapWeights[i];
588 const tmp<Field<Type>>& tmapF,
590 const UList<scalar>& mapWeights
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 851 Foam::Ostream& Foam::operator<<(Ostream& os, const Field<Type>&
f)
853 os << static_cast<const List<Type>&>(
f);
859 Foam::Ostream& Foam::operator<<(Ostream& os, const tmp<Field<Type>>& tf)
List< scalar > scalarList
List of scalar.
rho clamp_range(rhoMin[i], rhoMax[i])
void size(const label n)
Older name for setAddressableSize.
errorManipArg< error, int > exit(error &err, const int errNo=1)
patchWriters resize(patchIds.size())
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define COMPUTED_ASSIGNMENT(TYPE, op)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void negate()
Inplace negate this field (negative).
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
#define TFOR_ALL_F_OP_OP_F(typeF1, f1, OP1, OP2, typeF2, f2)
void clamp_min(const Type &lower)
Impose lower (floor) clamp on the field values (in-place)
constexpr char nl
The newline '\n' character (0x0a)
pTraits< Foam::vector >::cmptType cmptType
Component type.
virtual const labelListList & addressing() const
Return the interpolation addressing.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
void clamp_range(const Type &lower, const Type &upper)
Clamp field values (in-place) to the specified range.
virtual bool direct() const =0
Is it a direct (non-interpolating) mapper?
void writeEntry(const word &keyword, Ostream &os) const
Write the field as a dictionary entry.
bool uniform() const
True if all entries have identical values, and list is non-empty.
virtual const scalarListList & weights() const
Return the interpolation weights.
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
void replace(const direction, const UList< cmptType > &)
Replace a component field of the field.
virtual const labelUList & directAddressing() const
Return the direct addressing values.
List< labelList > labelListList
List of labelList.
UList< label > labelUList
A UList of labels.
#define TFOR_ALL_F_OP_S(typeF, f, OP, typeS, s)
#define forAll(list, i)
Loop across all elements in list.
virtual label size() const =0
The size of the mapper.
const dimensionedScalar e
Elementary charge.
Abstract base class to hold the Field mapping addressing and weights.
Generic templated field type.
List< scalarList > scalarListList
List of scalarList.
A class for handling words, derived from Foam::string.
VSForm block(const label start) const
auto key(const Type &t) -> std::enable_if_t< std::is_enum_v< Type >, std::underlying_type_t< Type > >
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
#define TFOR_ALL_F_OP_FUNC_S_S(typeF1, f1, OP, FUNC, typeS1, s1, typeS2, s2)
bool isNull(const T *ptr) noexcept
True if ptr is a pointer (of type T) to the nullObject.
void map(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 map from the given field
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
virtual const mapDistributeBase & distributeMap() const
Return the distribution map.
Class containing processor-to-processor mapping information.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
virtual bool distributed() const
Does the mapper have remote contributions?
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.
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
OBJstream os(runTime.globalPath()/outputName)
void operator=(const Field< Type > &)
Copy assignment.
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
void assign(const entry &e, const label len)
Assign from a primitive dictionary entry with the following behaviour:
void autoMap(const FieldMapper &map, const bool applyFlip=true)
Map from self.
#define TFOR_ALL_F_OP_FUNC_S_F(typeF1, f1, OP, FUNC, typeS, s, typeF2, f2)
void rmap(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 reverse-map from the given field
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
void clamp_max(const Type &upper)
Impose upper (ceiling) clamp on the field values (in-place)
bool notNull(const T *ptr) noexcept
True if ptr is not a pointer (of type T) to the nullObject.
const dimensionedScalar c
Speed of light in a vacuum.
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
tmp< Field< Type > > T() const
Return the field transpose (only defined for second rank tensors)
void writeEntry(Ostream &os) const
Write the UList with its compound type.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
List< label > labelList
A List of labels.
constexpr Field() noexcept
Default construct.
A class for managing temporary objects.
void normalise()
Inplace normalise this field. Generally a no-op except for vector fields.
Declaration macros for Field<Type> algebra.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
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 keyword and a list of tokens is an 'entry'.
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)
readOption
Enumeration defining read preferences.