FreeFOAM The Cross-Platform CFD Toolkit
DynamicField< T, SizeInc, SizeMult, SizeDiv > Class Template Reference

Dynamically sized Field. More...

#include <OpenFOAM/DynamicField.H>


Detailed Description

template<class T, unsigned SizeInc = 0, unsigned SizeMult = 2, unsigned SizeDiv = 1>
class Foam::DynamicField< T, SizeInc, SizeMult, SizeDiv >

Dynamically sized Field.

Source files

Definition at line 70 of file DynamicField.H.

+ Inheritance diagram for DynamicField< T, SizeInc, SizeMult, SizeDiv >:
+ Collaboration diagram for DynamicField< T, SizeInc, SizeMult, SizeDiv >:

List of all members.

Public Member Functions

 DynamicField ()
 Construct null.
 DynamicField (const label)
 Construct given size.
 DynamicField (const UList< T > &)
 Construct from UList. Size set to UList size.
 DynamicField (const Xfer< List< T > > &)
 Construct by transferring the parameter contents.
 DynamicField (const UList< T > &mapF, const labelList &mapAddressing)
 Construct by 1 to 1 mapping from the given field.
 DynamicField (const UList< T > &mapF, const labelListList &mapAddressing, const scalarListList &weights)
 Construct by interpolative mapping from the given field.
 DynamicField (const UList< T > &mapF, const FieldMapper &map)
 Construct by mapping from the given field.
 DynamicField (const DynamicField< T, SizeInc, SizeMult, SizeDiv > &)
 Construct copy.
 DynamicField (const Xfer< DynamicField< T, SizeInc, SizeMult, SizeDiv > > &)
 Construct by transferring the Field contents.
 DynamicField (Istream &)
 Construct from Istream. Size set to size of list read.
tmp< DynamicField< T, SizeInc,
SizeMult, SizeDiv > > 
clone () const
 Clone.
label capacity () const
 Size of the underlying storage.
void setCapacity (const label)
 Alter the size of the underlying storage.
void setSize (const label)
 Alter the addressed list size.
void setSize (const label, const T &)
 Alter the addressed list size and fill new space with a.
void resize (const label)
 Alter the addressed list size.
void resize (const label, const T &)
 Alter the addressed list size and fill new space with a.
void reserve (const label)
 Reserve allocation space for at least this size.
void clear ()
 Clear the addressed list, i.e. set the size to zero.
void clearStorage ()
 Clear the list and delete storage.
DynamicField< T, SizeInc,
SizeMult, SizeDiv > & 
shrink ()
 Shrink the allocated space to the number of elements used.
Xfer< List< T > > xfer ()
 Transfer contents to the Xfer container as a plain List.
DynamicField< T, SizeInc,
SizeMult, SizeDiv > & 
append (const T &)
 Append an element at the end of the list.
DynamicField< T, SizeInc,
SizeMult, SizeDiv > & 
append (const UList< T > &)
 Append a List at the end of this list.
T remove ()
 Remove and return the top element.
Toperator() (const label)
 Return non-const access to an element, resizing list if.
void operator= (const T &)
 Assignment of all addressed entries to the given value.
void operator= (const DynamicField< T, SizeInc, SizeMult, SizeDiv > &)
 Assignment from DynamicField.
void operator= (const UList< T > &)
 Assignment from UList.
- Public Member Functions inherited from Field< T >
 Field ()
 Construct null.
 Field (const label)
 Construct given size.
 Field (const label, const T &)
 Construct given size and initial value.
 Field (const UList< T > &)
 Construct as copy of a UList<Type>
 Field (const Xfer< List< T > > &)
 Construct by transferring the List contents.
 Field (const UList< T > &mapF, const unallocLabelList &mapAddressing)
 Construct by 1 to 1 mapping from the given field.
 Field (const tmp< Field< T > > &tmapF, const unallocLabelList &mapAddressing)
 Construct by 1 to 1 mapping from the given tmp field.
 Field (const UList< T > &mapF, const labelListList &mapAddressing, const scalarListList &weights)
 Construct by interpolative mapping from the given field.
 Field (const tmp< Field< T > > &tmapF, const labelListList &mapAddressing, const scalarListList &weights)
 Construct by interpolative mapping from the given tmp field.
 Field (const UList< T > &mapF, const FieldMapper &map)
 Construct by mapping from the given field.
 Field (const tmp< Field< T > > &tmapF, const FieldMapper &map)
 Construct by mapping from the given tmp field.
 Field (const Field< T > &)
 Construct as copy.
 Field (Field< T > &, bool reUse)
 Construct as copy or re-use as specified.
 Field (const Xfer< Field< T > > &)
 Construct by transferring the Field contents.
 Field (const typename Field< T >::subField &)
 Construct as copy of subField.
 Field (Istream &)
 Construct as copy of tmp<Field>
 Field (const word &keyword, const dictionary &dict, const label size)
 Construct from a dictionary entry.
void map (const UList< T > &mapF, const unallocLabelList &mapAddressing)
 1 to 1 map from the given field
void map (const tmp< Field< T > > &tmapF, const unallocLabelList &mapAddressing)
 1 to 1 map from the given tmp field
void map (const UList< T > &mapF, const labelListList &mapAddressing, const scalarListList &weights)
 Interpolative map from the given field.
void map (const tmp< Field< T > > &tmapF, const labelListList &mapAddressing, const scalarListList &weights)
 Interpolative map from the given tmp field.
void map (const UList< T > &mapF, const FieldMapper &map)
 Map from the given field.
void map (const tmp< Field< T > > &tmapF, const FieldMapper &map)
 Map from the given tmp field.
void autoMap (const FieldMapper &map)
 Map from self.
void rmap (const UList< T > &mapF, const unallocLabelList &mapAddressing)
 1 to 1 reverse-map from the given field
void rmap (const tmp< Field< T > > &tmapF, const unallocLabelList &mapAddressing)
 1 to 1 reverse-map from the given tmp field
void rmap (const UList< T > &mapF, const unallocLabelList &mapAddressing, const scalarList &weights)
 Interpolative reverse map from the given field.
void rmap (const tmp< Field< T > > &tmapF, const unallocLabelList &mapAddressing, const scalarList &weights)
 Interpolative reverse map from the given tmp field.
void negate ()
 Negate this field.
tmp< Field< cmptType > > component (const direction) const
 Return a component field of the field.
void replace (const direction, const UList< cmptType > &)
 Replace a component field of the field.
void replace (const direction, const tmp< Field< cmptType > > &)
 Replace a component field of the field.
void replace (const direction, const cmptType &)
 Replace a component field of the field.
tmp< Field< T > > T () const
 Return the field transpose (only defined for second rank tensors)
void writeEntry (const word &keyword, Ostream &os) const
 Write the field as a dictionary entry.
void operator= (const Field< T > &)
void operator= (const SubField< T > &)
void operator= (const tmp< Field< T > > &)
void operator= (const VectorSpace< Form, Cmpt, nCmpt > &)
void operator+= (const UList< T > &)
void operator+= (const tmp< Field< T > > &)
void operator+= (const T &)
void operator-= (const UList< T > &)
void operator-= (const tmp< Field< T > > &)
void operator-= (const T &)
void operator*= (const UList< scalar > &)
void operator*= (const tmp< Field< scalar > > &)
void operator*= (const scalar &)
void operator/= (const UList< scalar > &)
void operator/= (const tmp< Field< scalar > > &)
void operator/= (const scalar &)
- Public Member Functions inherited from refCount
 refCount ()
 Construct null with zero count.
int count () const
 Return the reference count.
bool okToDelete () const
 Return true if the reference count is zero.
void resetRefCount ()
 Reset the reference count to zero.
void operator++ ()
 Increment the reference count.
void operator++ (int)
 Increment the reference count.
void operator-- ()
 Decrement the reference count.
void operator-- (int)
 Decrement the reference count.
- Public Member Functions inherited from List< T >
 List ()
 Null constructor.
 List (const label)
 Construct with given size.
 List (const label, const T &)
 Construct with given size and value for all elements.
 List (const List< T > &)
 Copy constructor.
 List (const Xfer< List< T > > &)
 Construct by transferring the parameter contents.
 List (List< T > &, bool reUse)
 Construct as copy or re-use as specified.
 List (const UList< T > &, const unallocLabelList &mapAddressing)
 Construct as subset.
template<class InputIterator >
 List (InputIterator first, InputIterator last)
 Construct given start and end iterators.
template<unsigned Size>
 List (const FixedList< T, Size > &)
 Construct as copy of FixedList<T, Size>
 List (const PtrList< T > &)
 Construct as copy of PtrList<T>
 List (const SLList< T > &)
 Construct as copy of SLList<T>
 List (const IndirectList< T > &)
 Construct as copy of IndirectList<T>
 List (const UIndirectList< T > &)
 Construct as copy of UIndirectList<T>
 List (const BiIndirectList< T > &)
 Construct as copy of BiIndirectList<T>
 List (Istream &)
 Construct from Istream.
 ~List ()
label size () const
 Return the number of elements in the UList.
void append (const UIndirectList< T > &)
 Append a UIndirectList at the end of this list.
void transfer (List< T > &)
 Transfer the contents of the argument List into this list.
template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
void transfer (DynamicList< T, SizeInc, SizeMult, SizeDiv > &)
 Transfer the contents of the argument List into this list.
void transfer (SortableList< T > &)
 Transfer the contents of the argument List into this list.
TnewElmt (const label)
 Return subscript-checked element of UList.
void operator= (const List< T > &)
 Assignment operator. Takes linear time.
void operator= (const SLList< T > &)
 Assignment from SLList operator. Takes linear time.
void operator= (const IndirectList< T > &)
 Assignment from IndirectList operator. Takes linear time.
void operator= (const UIndirectList< T > &)
 Assignment from UIndirectList operator. Takes linear time.
void operator= (const BiIndirectList< T > &)
 Assignment from BiIndirectList operator. Takes linear time.
- Public Member Functions inherited from UList< T >
 UList ()
 Null constructor.
 UList (T *__restrict__ v, label size)
 Construct from components.
label fcIndex (const label i) const
 Return the forward circular index, i.e. the next index.
label rcIndex (const label i) const
 Return the reverse circular index, i.e. the previous index.
label byteSize () const
 Return the binary size in number of characters of the UList.
const Tcdata () const
 Return a const pointer to the first data element,.
Tdata ()
 Return a pointer to the first data element,.
void checkStart (const label start) const
 Check start is within valid range (0 ... size-1).
void checkSize (const label size) const
 Check size is within valid range (0 ... size).
void checkIndex (const label i) const
 Check index i is within valid range (0 ... size-1).
void writeEntry (Ostream &) const
 Write the UList as a dictionary entry.
void assign (const UList< T > &)
 Assign elements to those from UList.
Toperator[] (const label)
 Return element of UList.
const Toperator[] (const label) const
 Return element of constant UList.
 operator const Foam::List< T > & () const
 Allow cast to a const List<T>&.
iterator begin ()
 Return an iterator to begin traversing the UList.
iterator end ()
 Return an iterator to end traversing the UList.
const_iterator cbegin () const
 Return const_iterator to begin traversing the constant UList.
const_iterator cend () const
 Return const_iterator to end traversing the constant UList.
const_iterator begin () const
 Return const_iterator to begin traversing the constant UList.
const_iterator end () const
 Return const_iterator to end traversing the constant UList.
reverse_iterator rbegin ()
 Return reverse_iterator to begin reverse traversing the UList.
reverse_iterator rend ()
 Return reverse_iterator to end reverse traversing the UList.
const_reverse_iterator crbegin () const
 Return const_reverse_iterator to begin reverse traversing the UList.
const_reverse_iterator crend () const
 Return const_reverse_iterator to end reverse traversing the UList.
const_reverse_iterator rbegin () const
 Return const_reverse_iterator to begin reverse traversing the UList.
const_reverse_iterator rend () const
 Return const_reverse_iterator to end reverse traversing the UList.
label max_size () const
 Return size of the largest possible UList.
bool empty () const
 Return true if the UList is empty (ie, size() is zero).
void swap (UList< T > &)
 Swap two ULists of the same type in constant time.
bool operator== (const UList< T > &) const
 Equality operation on ULists of the same type.
bool operator!= (const UList< T > &) const
 The opposite of the equality operation. Takes linear time.
bool operator< (const UList< T > &) const
 Compare two ULists lexicographically. Takes linear time.
bool operator> (const UList< T > &) const
 Compare two ULists lexicographically. Takes linear time.
bool operator<= (const UList< T > &) const
 Return true if !(a > b). Takes linear time.
bool operator>= (const UList< T > &) const
 Return true if !(a < b). Takes linear time.
template<>
const bool & operator[] (const label i) const

Static Public Member Functions

static const DynamicField< T,
SizeInc, SizeMult, SizeDiv > & 
null ()
 Return a null field.
- Static Public Member Functions inherited from Field< T >
static tmp< Field< T > > NewCalculatedType (const Field< Type2 > &f)
 Return a pointer to a new calculatedFvPatchFieldField created on.

Friends

Ostreamoperator (Ostream &, const DynamicField< T, SizeInc, SizeMult, SizeDiv > &)
Istreamoperator>> (Istream &, DynamicField< T, SizeInc, SizeMult, SizeDiv > &)
 Read from Istream, discarding contents of existing DynamicField.

Additional Inherited Members

- Public Types inherited from Field< T >
typedef pTraits< T >::cmptType cmptType
 Component type.
typedef SubField< TsubField
 Declare type of subField.
- Public Types inherited from List< T >
typedef SubList< TsubList
 Declare type of subList.
- Public Types inherited from UList< T >
typedef T value_type
 Type of values the UList contains.
typedef Treference
 Type that can be used for storing into.
typedef const Tconst_reference
 Type that can be used for storing into.
typedef label difference_type
 The type that can represent the difference between any two.
typedef label size_type
 The type that can represent the size of a UList.
typedef Titerator
 Random access iterator for traversing UList.
typedef const Tconst_iterator
 Random access iterator for traversing UList.
typedef Treverse_iterator
 Reverse iterator for reverse traversal of UList.
typedef const Tconst_reverse_iterator
 Reverse iterator for reverse traversal of constant UList.
- Static Public Attributes inherited from Field< T >
static const char *const typeName

Constructor & Destructor Documentation

DynamicField ( )
inline

Construct null.

Definition at line 29 of file DynamicFieldI.H.

DynamicField ( const label  nElem)
inlineexplicit

Construct given size.

Definition at line 38 of file DynamicFieldI.H.

References List< Type >::size().

DynamicField ( const UList< T > &  lst)
inlineexplicit

Construct from UList. Size set to UList size.

Also constructs from DynamicField with different sizing parameters.

Definition at line 52 of file DynamicFieldI.H.

DynamicField ( const Xfer< List< T > > &  lst)
inlineexplicit

Construct by transferring the parameter contents.

Definition at line 63 of file DynamicFieldI.H.

DynamicField ( const UList< T > &  mapF,
const labelList mapAddressing 
)
inline

Construct by 1 to 1 mapping from the given field.

Definition at line 74 of file DynamicFieldI.H.

DynamicField ( const UList< T > &  mapF,
const labelListList mapAddressing,
const scalarListList weights 
)
inline

Construct by interpolative mapping from the given field.

Definition at line 86 of file DynamicFieldI.H.

DynamicField ( const UList< T > &  mapF,
const FieldMapper map 
)
inline

Construct by mapping from the given field.

Definition at line 100 of file DynamicFieldI.H.

DynamicField ( const DynamicField< T, SizeInc, SizeMult, SizeDiv > &  lst)
inline

Construct copy.

Definition at line 112 of file DynamicFieldI.H.

DynamicField ( const Xfer< DynamicField< T, SizeInc, SizeMult, SizeDiv > > &  lst)
inline

Construct by transferring the Field contents.

Definition at line 123 of file DynamicFieldI.H.

DynamicField ( Istream is)
explicit

Construct from Istream. Size set to size of list read.

Definition at line 31 of file DynamicField.C.


Member Function Documentation

static const DynamicField<T, SizeInc, SizeMult, SizeDiv>& null ( )
inlinestatic

Return a null field.

Reimplemented from Field< T >.

Definition at line 85 of file DynamicField.H.

References reinterpret_cast().

Foam::tmp< Foam::DynamicField< T, SizeInc, SizeMult, SizeDiv > > clone ( ) const

Clone.

Reimplemented from Field< T >.

Definition at line 40 of file DynamicField.C.

Foam::label capacity ( ) const
inline

Size of the underlying storage.

Definition at line 135 of file DynamicFieldI.H.

void setCapacity ( const label  nElem)
inline

Alter the size of the underlying storage.

The addressed size will be truncated if needed to fit, but will remain otherwise untouched. Use this or reserve() in combination with append().

Definition at line 144 of file DynamicFieldI.H.

References List< Type >::setSize(), and List< Type >::size().

void setSize ( const label  nElem)
inline

Alter the addressed list size.

New space will be allocated if required. Use this to resize the list prior to using the operator[] for setting values (as per List usage).

Reimplemented from List< T >.

Definition at line 202 of file DynamicFieldI.H.

References Foam::max(), List< Type >::setSize(), and List< Type >::size().

void setSize ( const label  nElem,
const T t 
)
inline

Alter the addressed list size and fill new space with a.

constant.

Reimplemented from List< T >.

Definition at line 239 of file DynamicFieldI.H.

References setSize(), and List< Type >::size().

void resize ( const label  nElem)
inline

Alter the addressed list size.

New space will be allocated if required. Use this to resize the list prior to using the operator[] for setting values (as per List usage).

Reimplemented from List< T >.

Definition at line 257 of file DynamicFieldI.H.

References setSize().

void resize ( const label  nElem,
const T t 
)
inline

Alter the addressed list size and fill new space with a.

constant.

Reimplemented from List< T >.

Definition at line 267 of file DynamicFieldI.H.

References setSize().

void reserve ( const label  nElem)
inline

Reserve allocation space for at least this size.

Never shrinks the allocated size, use setCapacity() for that.

Definition at line 165 of file DynamicFieldI.H.

References Foam::max(), List< Type >::setSize(), and List< Type >::size().

void clear ( )
inline

Clear the addressed list, i.e. set the size to zero.

Allocated size does not change

Reimplemented from List< T >.

Definition at line 277 of file DynamicFieldI.H.

References List< Type >::size().

void clearStorage ( )
inline

Clear the list and delete storage.

Definition at line 284 of file DynamicFieldI.H.

References List< Type >::clear().

Foam::DynamicField< T, SizeInc, SizeMult, SizeDiv > & shrink ( )
inline

Shrink the allocated space to the number of elements used.

Returns a reference to the DynamicField.

Definition at line 293 of file DynamicFieldI.H.

References List< Type >::setSize(), and List< Type >::size().

Foam::Xfer< Foam::List< T > > xfer ( )
inline

Transfer contents to the Xfer container as a plain List.

Reimplemented from List< T >.

Definition at line 312 of file DynamicFieldI.H.

Foam::DynamicField< T, SizeInc, SizeMult, SizeDiv > & append ( const T t)
inline

Append an element at the end of the list.

Definition at line 321 of file DynamicFieldI.H.

References setSize(), and List< T >::size().

Foam::DynamicField< T, SizeInc, SizeMult, SizeDiv > & append ( const UList< T > &  lst)
inline

Append a List at the end of this list.

Reimplemented from List< T >.

Definition at line 336 of file DynamicFieldI.H.

References Foam::abort(), Foam::FatalError, FatalErrorIn, forAll, setSize(), List< T >::size(), and UList< T >::size().

T remove ( )
inline

Remove and return the top element.

Definition at line 361 of file DynamicFieldI.H.

References Foam::abort(), Foam::FatalError, FatalErrorIn, UList< T >::operator[](), List< T >::size(), and Foam::T().

T & operator() ( const label  elemI)
inline

Return non-const access to an element, resizing list if.

necessary

Definition at line 385 of file DynamicFieldI.H.

References setSize().

void operator= ( const T t)
inline

Assignment of all addressed entries to the given value.

Reimplemented from Field< T >.

Definition at line 400 of file DynamicFieldI.H.

References UList< T >::operator=().

void operator= ( const DynamicField< T, SizeInc, SizeMult, SizeDiv > &  lst)
inline
void operator= ( const UList< T > &  lst)
inline

Assignment from UList.

Reimplemented from Field< T >.

Definition at line 442 of file DynamicFieldI.H.

References Field< Type >::operator=(), List< Type >::size(), and UList< T >::size().


Friends And Related Function Documentation

Ostream& operator ( Ostream ,
const DynamicField< T, SizeInc, SizeMult, SizeDiv > &   
)
friend
Istream& operator>> ( Istream ,
DynamicField< T, SizeInc, SizeMult, SizeDiv > &   
)
friend

Read from Istream, discarding contents of existing DynamicField.


The documentation for this class was generated from the following files: