/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
Class
Foam::DynamicField
Description
Dynamically sized Field.
SourceFiles
DynamicFieldI.H
DynamicField.C
\*---------------------------------------------------------------------------*/
#ifndef DynamicField_H
#define DynamicField_H
#include "Field.H"
#include
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declarations
template class DynamicField;
template
Ostream& operator<<
(
Ostream& os,
const DynamicField& fld
);
template
Istream& operator>>
(
Istream& is,
DynamicField& fld
);
/*---------------------------------------------------------------------------*\
Class DynamicField Declaration
\*---------------------------------------------------------------------------*/
template
class DynamicField
:
public Field
{
static_assert(SizeMin > 0, "Invalid min size parameter");
// Private data
//- The capacity (allocated size) of the underlying field.
label capacity_;
// Private Member Functions
//- Copy assignment from another list
template
inline void assignDynField(const ListType& list);
public:
// Static Member Functions
//- Return a null field
inline static const DynamicField& null()
{
return NullObjectRef>();
}
// Constructors
//- Construct null
inline constexpr DynamicField() noexcept;
//- Construct empty field with given reserve size.
inline explicit DynamicField(const label len);
//- Construct given size and initial value
inline DynamicField(const label len, const T& val);
//- Construct given size and initial value of zero
inline DynamicField(const label len, const Foam::zero);
//- Copy construct
inline DynamicField(const DynamicField& list);
//- Copy construct with different sizing parameters
template
inline DynamicField(const DynamicField& list);
//- Copy construct from UList. Size set to UList size.
// Also constructs from DynamicField with different sizing parameters.
inline explicit DynamicField(const UList& list);
//- Copy construct from IndirectList
template
inline explicit DynamicField(const IndirectListBase& list);
//- Move construct from List contents
inline explicit DynamicField(List&& content);
//- Move construct from dynamic Field contents
inline DynamicField(DynamicField&& content);
//- Move construct with different sizing parameters
template
inline DynamicField(DynamicField&& content);
//- Construct by 1 to 1 mapping from the given field
inline DynamicField
(
const UList& mapF,
const labelUList& mapAddressing
);
//- Construct by interpolative mapping from the given field
inline DynamicField
(
const UList& mapF,
const labelListList& mapAddressing,
const scalarListList& weights
);
//- Construct by mapping from the given field
inline DynamicField
(
const UList& mapF,
const FieldMapper& map
);
//- Construct from Istream. Size set to size of list read.
explicit DynamicField(Istream& is);
//- Clone
tmp> clone() const;
// Member Functions
// Access
//- Size of the underlying storage.
inline label capacity() const noexcept;
// Edit
//- 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().
inline void setCapacity(const label nElem);
//- 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).
inline void setSize(const label nElem);
//- Alter the addressed list size and fill new space with a constant.
inline void setSize(const label nElem, const T& val);
//- 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).
inline void resize(const label nElem);
//- Alter the addressed list size and fill new space with a
// constant.
inline void resize(const label nElem, const T& val);
//- Reserve allocation space for at least this size.
// Never shrinks the allocated size, use setCapacity() for that.
inline void reserve(const label nElem);
//- Clear the addressed list, i.e. set the size to zero.
// Allocated size does not change
inline void clear();
//- Clear the list and delete storage.
inline void clearStorage();
//- Expand the addressable size to fit the allocated capacity.
// Returns the previous addressable size.
inline label expandStorage();
//- Shrink the allocated space to the number of elements used.
// Returns a reference to the DynamicField.
inline DynamicField& shrink();
//- Swap content with any sized DynamicField
template
inline void swap(DynamicField& list);
//- Transfer the parameter contents into this
inline void transfer(List& list);
//- Transfer the parameter contents into this
template
inline void transfer(DynamicList& list);
//- Transfer the parameter contents into this
template
inline void transfer(DynamicField& list);
//- Append an element at the end of the list
inline DynamicField&
append(const T& val);
//- Append a List at the end of this list
inline DynamicField&
append(const UList& list);
//- Remove and return the top element
inline T remove();
// Member Operators
//- Return non-const access to an element, resizing list if necessary
inline T& operator()(const label i);
//- Assign addressed entries to the given value
inline void operator=(const T& val);
//- Copy assignment
inline void operator=(const UList& list);
//- Copy assignment
inline void operator=(const DynamicField& list);
//- Move assignment
inline void operator=(List&& list);
//- Move assignment
inline void operator=(DynamicField&& list);
//- Move assignment
template
inline void operator=(DynamicField&& list);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "DynamicFieldI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "DynamicField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //