44 List<Type>(mapAddressing.size())
46 map(mapF, mapAddressing);
57 List<Type>(mapAddressing.size())
59 map(tmapF, mapAddressing);
71 List<Type>(mapAddressing.size())
73 map(mapF, mapAddressing, mapWeights);
85 List<Type>(mapAddressing.size())
87 map(tmapF, mapAddressing, mapWeights);
99 List<Type>(mapper.size())
101 map(mapF, mapper, applyFlip);
110 const Type& defaultValue,
114 List<Type>(mapper.size(), defaultValue)
116 map(mapF, mapper, applyFlip);
129 List<Type>(defaultValues)
131 map(mapF, mapper, applyFlip);
143 List<Type>(mapper.size())
145 map(tmapF, mapper, applyFlip);
154 const Type& defaultValue,
158 List<Type>(mapper.size(), defaultValue)
160 map(tmapF, mapper, applyFlip);
175 map(tmapF, mapper, applyFlip);
197 if (IOobjectOption::isReadOptional(readOpt))
205 if (len > 0) this->
resize(len);
218 ITstream& is =
e.stream();
221 token firstToken(is);
223 if (firstToken.isWord(
"uniform"))
228 this->resize_nocopy(len);
230 operator=(pTraits<Type>(is));
232 else if (firstToken.isWord(
"nonuniform"))
234 is >>
static_cast<List<Type>&
>(*this);
235 const label lenRead = this->size();
238 if (len >= 0 && len != lenRead)
240 if (len < lenRead && allowConstructFromLargerSize)
247 <<
"Sizes do not match. Truncating " << lenRead
248 <<
" entries to " << len <<
endl;
254 <<
"Size " << lenRead
255 <<
" is not equal to the expected length " << len
263 <<
"Expected keyword 'uniform' or 'nonuniform', found " 264 << firstToken.info() <<
nl 275 const dictionary&
dict,
277 IOobjectOption::readOption readOpt
284 else if (readOpt != IOobjectOption::NO_READ)
286 const entry* eptr =
dict.findEntry(
key, keyType::LITERAL);
295 if (IOobjectOption::isReadRequired(readOpt))
298 <<
"Required entry '" <<
key <<
"' missing in dictionary " 299 <<
dict.relativeName() <<
nl 317 if (
f.size() != mapAddressing.
size())
319 f.resize(mapAddressing.
size());
326 const label mapI = mapAddressing[i];
340 const tmp<Field<Type>>& tmapF,
344 map(tmapF(), mapAddressing);
359 if (
f.size() != mapAddressing.
size())
361 f.resize(mapAddressing.
size());
364 if (mapWeights.
size() != mapAddressing.
size())
367 << mapWeights.
size() <<
" map size: " << mapAddressing.
size()
373 const labelList& localAddrs = mapAddressing[i];
374 const scalarList& localWeights = mapWeights[i];
380 f[i] += localWeights[j]*mapF[localAddrs[j]];
389 const tmp<Field<Type>>& tmapF,
394 map(tmapF(), mapAddressing, mapWeights);
426 else if (!mapper.
direct())
435 this->transfer(newMapF);
461 const tmp<Field<Type>>& tmapF,
462 const FieldMapper& mapper,
466 map(tmapF(), mapper, applyFlip);
500 this->map(fCpy, mapper);
507 this->transfer(fCpy);
523 Field<Type> fCpy(*
this);
537 const UList<Type>& mapF,
541 Field<Type>&
f = *
this;
545 label mapI = mapAddressing[i];
558 const tmp<Field<Type>>& tmapF,
562 rmap(tmapF(), mapAddressing);
581 f[mapAddressing[i]] += mapF[i]*mapWeights[i];
589 const tmp<Field<Type>>& tmapF,
591 const UList<scalar>& mapWeights
594 rmap(tmapF(), mapAddressing, mapWeights);
666 for (
auto& val : *
this)
677 for (
auto& val : *
this)
691 for (
auto& val : *
this)
705 template<
class VSForm>
711 vs[i] = this->operator[](start + i);
731 os.writeKeyword(keyword);
739 os << word(
"uniform") << token::SPACE << List<Type>::front();
743 os << word(
"nonuniform") << token::SPACE;
768 if (
this == &(rhs()))
778 template<
class Form,
class Cmpt, Foam::direction nCmpt>
785 #define COMPUTED_ASSIGNMENT(TYPE, op) \ 787 template<class Type> \ 788 void Foam::Field<Type>::operator op(const UList<TYPE>& f) \ 790 TFOR_ALL_F_OP_F(Type, *this, op, TYPE, f) \ 793 template<class Type> \ 794 void Foam::Field<Type>::operator op(const tmp<Field<TYPE>>& tf) \ 800 template<class Type> \ 801 void Foam::Field<Type>::operator op(const TYPE& t) \ 803 TFOR_ALL_F_OP_S(Type, *this, op, TYPE, t) \ 811 #undef COMPUTED_ASSIGNMENT 817 Foam::Ostream& Foam::operator<<(Ostream& os, const Field<Type>&
f)
819 os << static_cast<const List<Type>&>(
f);
825 Foam::Ostream& Foam::operator<<(Ostream& os, const tmp<Field<Type>>& tf)
List< scalar > scalarList
List of scalar.
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?
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
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
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.
OBJstream os(runTime.globalPath()/outputName)
void operator=(const Field< Type > &)
Copy assignment.
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
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
#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)
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
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.
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 List< 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.