FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Related Symbols | List of all members
Fiber::Field Class Reference

A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID objects. More...

#include <Field.hpp>

Inheritance diagram for Fiber::Field:
Fiber::Ownable< Field > MemCore::Intercube Fiber::FragmentIDCollectionProvider MemCore::Ageable Fiber::SaveableAttributes Fiber::OwnerBase MemCore::Attributes Fiber::ComputationalField< FieldOperator > Fiber::RegularlyFragmentedField< DIMS >

Public Types

enum class  CreationFailAlternative { Fail , Persistent , Discardable }
 
using fragments_t = FlatMap< FragmentIndex_t, RefPtr< CreativeArrayBase > >
 
using fragment_mutex_t = MemCore::shared_mutex
 
using CAB_t = RefPtr< CreativeArrayBase >
 
typedef WeakPtr< Field, Field::reference_domain_t > WeakFieldPtr_t
 
using NamedFragment = std::pair< RefPtr< CreativeArrayBase >, RefPtr< FragmentID > >
 
using Iterator = FragmentIterator
 
using FragmentIterator_t = std::function< bool(const RefPtr< FragmentID > &, const RefPtr< CreativeArrayBase > &)>
 Callback type for functions iterating over Field fragments.
 
- Public Types inherited from Fiber::OwnerBase
template<class ItemType >
using Item = MemCore::InterfaceData< ItemType >
 An optional convenience class that allows to easily add arbitrary types to Intercubes .
 

Public Member Functions

void reserve_fragments (size_t N)
 
void extremeUnction () override
 
void clear ()
 Remove all fragments of this Field.
 
FragmentIndex_t getNumericalID (const RefPtr< FragmentID > &fid)
 
FragmentIndex_t findNumericalID (const RefPtr< FragmentID > &fid) const
 
FragmentIndex_t findNumericalIDByName (const string &FragmentName) const
 
RefPtr< FragmentID > & makeFragmentID (const string &fragmentname)
 Create a new fragment ID if not existent yet.
 
RefPtr< FragmentID > & operator[] (const string &fragmentname)
 
RefPtr< FragmentIDCollectiongetFragmentIDCollection () const override
 
DynamicSize getFragmentLayout () const
 
const FragmentIDCollection::FragmentIDs_tgetFragmentIDs () const
 Return iteratable container of fragment ID's for this field.
 
 Field ()
 Default constructor, no data or fragments.
 
 Field (const RefPtr< FragmentIDCollection > &theFragmentIDCollection)
 Create a new field from an existing FragmentID collection, such as an existing field.
 
 Field (const WeakPtr< Field > &SimilarField)
 
 Field (const FragmentIDCollectionProvider &FICP)
 
 Field (const RefPtr< CreativeArrayBase > &FFC, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Create unfragmented field with data creation via Creator.
 
 Field (const RefPtr< MemBase > &Mb, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Create unfragmented field with data stored always in memory ( calls setPersistentData() )
 
 Field (const RefPtr< CreativeArrayBase > &FFC, const WeakPtr< Field > &SimilarField)
 
 Field (const RefPtr< MemBase > &MAb, const WeakPtr< Field > &SimilarField)
 
 Field (const RefPtr< CreativeArrayBase > &FFC, const FragmentIDCollectionProvider &FICP)
 
 Field (const RefPtr< MemBase > &MAb, const FragmentIDCollectionProvider &FICP)
 
 Field (const RefPtr< MemBase > &Mb, const RefPtr< MemCore::Cache > &Cache, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Create unfragmented field with data stored in memory as long as the cache allows. ( calls setPersistentData() )
 
template<Dims_t DIMS>
 Field (const MultiIndex< DIMS > &NumberOfFragments, const string &FragmentNamePrefix)
 Create a field with a multi-dimensional regular layout for the fragments.
 
template<Dims_t DIMS>
bool setFragmentLayout (const MultiIndex< DIMS > &NumberOfFragments, const string &FragmentNamePrefix)
 Add a multi-dimensional regular layout for the fragments if it had no layout yet.
 
RefPtr< MemBasenewFragmentationArray () const
 For fields with a fragment layout provide such in a MultiArray.
 
template<class T , Dims_t N>
 Field (const MemCore::Ref< MemArray< N, T > > &MemRefPtr, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Convenience function initializing from a Ref<> to some MemArray.
 
template<class T , Dims_t N>
 Field (const MemCore::RefPtr< MemArray< N, T > > &MemRefPtr, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Convenience function initializing from a RefPtr<> to some MemArray.
 
template<class T , Dims_t N>
 Field (const MemCore::WeakPtr< MemArray< N, T > > &MemRefPtr, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Convenience function initializing from a RefPtr<> to some MemArray.
 
template<class T , Dims_t N>
 Field (const MemCore::MemVector< T > &Data, const MultiIndex< N > &Size, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Construct an unfragmented field from a MemVector and a MultiIndex.
 
template<class T , Dims_t N>
 Field (const MemCore::RefPtr< MemCore::TypedChunk< T > > &Data, const MultiIndex< N > &Size, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Construct an unfragmented field from a Chunk of data and multidimensional index.
 
void own (CreativeArrayBase &CAB)
 
void own (const RefPtr< CreativeArrayBase > &CAB)
 
bool hasData (const RefPtr< FragmentID > &FID=nullptr) const
 Check if there are data on this field fragment.
 
const CAB_tsetPersistentData (const RefPtr< MemBase > &Mb, const RefPtr< FragmentID > &=nullptr, const RefPtr< MemCore::Cache > &Cache=MemCore::Cache::MemCache(), const string &ProvenanceInfo={})
 Set data for a certain field fragment that is always kept in memory, the cache reference is just use to trace memory utilization.
 
const CAB_tsetPersistentData (const RefPtr< MemBase > &Mb, const RefPtr< FragmentID > &fID, const string &ProvenanceInfo)
 
const CAB_tsetPersistentDataByName (const RefPtr< MemBase > &Mb, const string &FragmentName, const RefPtr< MemCore::Cache > &Cache=MemCore::Cache::MemCache())
 
template<class T , Dims_t N>
const CAB_tsetPersistentData (const MemCore::RefPtr< Chunk< T > > &Mb, const MultiIndex< N > &Dimensions, const RefPtr< FragmentID > &FragID=nullptr, const RefPtr< MemCore::Cache > &Cache=MemCore::Cache::MemCache())
 A convenience function to set a field's data from a Chunk of data.
 
template<class T , Dims_t N>
const CAB_tsetPersistentData (Chunk< T > *Mb, const MultiIndex< N > &Dimensions, const RefPtr< FragmentID > &FragID=nullptr, const RefPtr< MemCore::Cache > &Cache=MemCore::Cache::MemCache())
 A convenience function to set a field's data from a Chunk of data.
 
template<class T >
const CAB_tsetPersistentData1D (const MemCore::RefPtr< Chunk< T > > &data, const RefPtr< FragmentID > &FragID=nullptr, const RefPtr< MemCore::Cache > &Cache=MemCore::Cache::MemCache())
 A convenience function to set a field's data from a Chunk of data, interpreting them as one-dimensional.
 
RefPtr< MemArrayPropertiesgetProperties () const
 Return properties associated with this field.
 
const type_infogetFieldStorageType () const
 Get the type of the field.
 
const type_infogetElementType () const
 Retrieve the element type of this field, which is stored with the properties of this field.
 
MemCore::WeakPtr< FiberTypeBasegetElementFiberType () const
 Retrieve the fiber type that is associated with this field.
 
MemCore::WeakPtr< FiberTypeBasegetFiberType () const
 
int getMemoryUsage (memsize_t &UsedMemory, memsize_t &WantedMemory) const
 Get the memory occupied by this field (and all of its fragments).
 
bool isType (const TypeList_t &TL) const
 Check if the type of this field is contained in the given type list.
 
FiberTypeIndex getFiberTypeIndex () const
 
bool addFiberType (TypeList_t &TypeList) const
 Add the type used by this field to the given TypeList.
 
const RefPtr< CreativeArrayBase > & setCreator (const RefPtr< CreativeArrayBase > &FFC, const RefPtr< FragmentID > &=nullptr)
 Sets the creator for an unfragmented field.
 
const RefPtr< CreativeArrayBase > & setCreatorByName (const RefPtr< CreativeArrayBase > &FFC, const string &FragmentName)
 
const RefPtr< CreativeArrayBase > & setCompatibleCreator (const RefPtr< CreativeArrayBase > &CAB, const RefPtr< FragmentID > &fid=nullptr)
 Set the creator for a fragment ID on a different Skeleton such that the fragment IDs are different, only their names matching.
 
FunctionalCreatorsetLambda (const FunctionalCreator::Functor &F, const RefPtr< FragmentID > &fid=nullptr)
 
FunctionalCreatorsetLambda (const RefPtr< FragmentID > &fid, const FunctionalCreator::Functor &F)
 
FunctionalCreatorsetCompatibleLambda (const FunctionalCreator::Functor &F, const RefPtr< FragmentID > &fid=nullptr)
 
const RefPtr< CreativeArrayBase > & setFunctionalCreator (const FunctionalCreator::Functor &F, const RefPtr< FragmentID > &fid=nullptr)
 
template<class Functor >
FunctionalCreatorsetFunctor (const Functor &F, const RefPtr< FragmentID > &fid=nullptr)
 Alias for setLambda().
 
template<class Functor >
FunctionalCreatorsetFunctor (const RefPtr< FragmentID > &fid, const Functor &F)
 Alias for setLambda().
 
size_t nFragments () const
 The number of fragments in this field.
 
size_t NumberOfFragments () const
 The number of fragments in this field.
 
bool isUnfragmented () const
 
bool isFragmented () const
 
RefPtr< FragmentIDgetFragmentID (const string &FragmentName) const
 
RefPtr< FragmentIDoperator() (const string &FragmentName) const
 
RefPtr< CreativeArrayBasegetCreator (const RefPtr< FragmentID > &=nullptr) const
 Get the creator of an unfragmented field.
 
RefPtr< CreativeArrayBaseoperator() (const RefPtr< FragmentID > &FID=nullptr) const
 
RefPtr< CreativeArrayBasegetCreatorByName (const string &FragmentName) const
 Get the creator of an unfragmented field via the textual description of a fragment ID.
 
NamedFragment getCreatorByNameF (const string &FragmentName) const
 
RefPtr< CreativeArrayBasegetCreatorByNumericalID (FragmentIndex_t NumericalID) const
 
RefPtr< CreativeArrayBase > & getCreatorReferenceViaFragmentIndex (FragmentIndex_t NumericalID)
 
RefPtr< CreativeArrayBasegetCreator (FragmentIndex_t NumericalID) const
 
RefPtr< CreativeArrayBasegetCompatibleCreator (const RefPtr< FragmentID > &F=nullptr) const
 Get a creator from a fragment ID that is NAMED similar to one fragment here.
 
NamedFragment getCompatibleCreatorF (const RefPtr< FragmentID > &F=nullptr) const
 Get a creator from a fragment ID that is NAMED similar to one fragment here.
 
RefPtr< MemBasegetData (const RefPtr< FragmentID > &FID=nullptr) const
 Get the data of a contigous field.
 
RefPtr< MemBasegetDataByNumericalID (FragmentIndex_t NumericalID) const
 Get some fragment's data via its numerical fragment ID.
 
 DEPRECATED ("Use function getDataByNumericalID() instead", RefPtr< MemBase > getData(FragmentIndex_t NumericalID) const)
 
RefPtr< MemBasegetFirstData () const
 In case this is field is fragmented, but there is only one fragment, return the ID of this singular fragment.
 
RefPtr< CreativeArrayBasegetFirstCreator () const
 In case this is field is fragmented, but there is only one fragment, return the ID of this singular fragment.
 
RefPtr< FragmentIDgetFirstFragmentID () const
 Get the first fragment ID.
 
RefPtr< MemCore::ChunkBasegetChunk (const RefPtr< FragmentID > &FID=nullptr) const
 Return the stored memory chunk associated with this array.
 
RefPtr< MemBasegetCompatibleData (const RefPtr< FragmentID > &F=nullptr) const
 Get data from a fragment ID that is NAMED similar to one fragment here.
 
unsigned iterate (FragmentIterator &, const MemCore::WeakPtr< FragmentSelector > &FS=nullptr) const
 
template<class T >
unsigned Iterate (const T &t, const MemCore::WeakPtr< FragmentSelector > &FS=nullptr) const
 
template<class T >
unsigned iterate_fragments (const T &t, const MemCore::WeakPtr< FragmentSelector > &FS=nullptr) const
 
Ageable getMostRecentCreatorAge () const
 
Ageable getMostRecentAttributeAge () const
 
bool hasFragmentsNewerThan (const Ageable &A) const
 
unsigned iterate (const FragmentIterator_t &FI, bool parallel=false, bool copy_map_internally=false) const
 
unsigned iterate (bool parallel, const FragmentIterator_t &FI, bool copy_map_internally=false) const
 Same as iterate(const FragmentIterator_t&, bool), just other order of arguments for convenience.
 
unsigned iterate_parallel (const FragmentIterator_t &FI, bool copy_map_internally=false) const
 Iterate over all fragments in parallel.
 
unsigned iterate (FragmentIndexIterator &FFI, const WeakPtr< FragmentSelector > &FS=nullptr, bool copy_map_internally=false) const
 Iterate over the fragments of a field using the integer ID of each fragment.
 
Dims_t Dims () const
 The dimensionality of the field, taken from the getProperties().
 
RefPtr< SizeInterfacegetSize () const
 The size of the field, which is the sum of all fragments.
 
bool isCompatible (const Field &F)
 
void Speak (int indent=0, int maxindent=-1) const
 Informative debug message.
 
string xml () const
 
RefPtr< CreativeArrayBasecreateCreator (const RefPtr< MemBase > &Data, const RefPtr< FragmentID > &=nullptr, CreationFailAlternative=CreationFailAlternative::Persistent, const WeakPtr< MemCore::Cache > &theCache=MemCore::Cache::MemCache())
 Insert some data into a Field with various memory management methods.
 
RefPtr< CreativeArrayBasecreateCreator (const RefPtr< MemBase > &Data, const string &FragmentName, CreationFailAlternative=CreationFailAlternative::Persistent, const WeakPtr< MemCore::Cache > &theCache=MemCore::Cache::MemCache())
 
template<Dims_t N, class T >
std::pair< RefPtr< MemArray< N, T > >, RefPtr< CreativeArrayBase > > createData (const MultiIndex< N > &Size, const RefPtr< FragmentID > &fid=nullptr, Field::CreationFailAlternative FailMode=Field::CreationFailAlternative::Persistent, const WeakPtr< MemCore::Cache > &theCache=MemCore::Cache::MemCache())
 Create a mem array and insert it as a fragment to the Field.
 
template<Dims_t N, class T >
std::pair< RefPtr< MemArray< N, T > >, RefPtr< CreativeArrayBase > > createData (const MultiIndex< N > &Size, const string &fragmentname, Field::CreationFailAlternative FailMode=Field::CreationFailAlternative::Persistent, const WeakPtr< MemCore::Cache > &theCache=MemCore::Cache::MemCache())
 Create a mem array and insert it as a fragment to the Field under the given fragmentname:
 
template<Dims_t Dims>
MultiIndex< Dims > & setFragmentOffset (const string &FragmentName, const MultiIndex< Dims > &Offset)
 Set a fragment's index offset.
 
- Public Member Functions inherited from Fiber::Ownable< Field >
void x_updateOwnershipAge (const MemCore::Ageable &theNewAge) override
 Forward some age to all Owners.
 
void insertOwner (const Container &theOwner)
 Add some owner.
 
bool insertOwner (const MemCore::WeakPtr< Container > &theOwner)
 Add some owner.
 
void addOwner (const Container &theOwner, const MemCore::Ageable &theNewAge)
 Add some owner and broadcast a new age to all Ownerrs.
 
void addOwner (const MemCore::WeakPtr< Container > &theOwner, const MemCore::Ageable &theNewAge)
 Add some owner and broadcast a new age to all Ownerrs.
 
 Ownable ()
 Default constructor, empty Ownership list.
 
 Ownable (const Ownable &)
 Copy constructor, does NOT copy any ownership information, the new Ownable will be unowned.
 
 Ownable (const MemCore::WeakPtr< Container > &theOwner, const MemCore::Ageable &theNewAge)
 Construct an Ownable with an initial owner.
 
 Ownable (const Container &theOwner, const MemCore::Ageable &theNewAge)
 Construct an Ownable with an initial owner.
 
Ownableoperator= (const Ownable &)
 Assignment, does NOT copy any ownership information, the assigned Ownable will retain all its ownership information.
 
MemCore::WeakPtr< Container > getPrimaryOwner () const
 Get the first valid owner.
 
size_t getNumberOfValidOwners () const
 Get the first valid owner.
 
bool processOwnership (MemCore::Intercube &Output, const MemCore::Intercube &Input) const override
 Process some ownership action.
 
- Public Member Functions inherited from Fiber::OwnerBase
bool processOwnership (MemCore::Intercube &OutputAndInput) const
 Process ownership where the input information is shared with the output information in the same Intercube.
 
- Public Member Functions inherited from MemCore::Intercube
void addInterface (const RefPtr< InterfaceBase > &I) const
 
void addInterfaceData (const Data &D)
 
void addInterfaceData (const Data &D)
 
void clearInterfaces ()
 
bool const_iterateInterfaces (const RefPtr< InterfaceIterationParameter > &IIP) const
 
virtual RefPtr< InterfaceBasecreateInterface (const type_info &) const
 
RefPtr< InterfaceBasefindInterface (const type_info &t) const
 
RefPtr< InterfaceBasegetInterface (const type_info &t)
 
std::string getInterfaceNames (const char delim=';') const
 
bool gotNewInterfaceData (const Data &D)
 
bool gotNewInterfaceData (mutex &M, const Data &D)
 
bool gotNewInterfaceData (mutex &M, const Data &D)
 
bool gotNewInterfaceData (mutex &M, const Data &D, const Selector &S)
 
bool gotNewInterfaceData (mutex &M, const Data &D, const Selector *S)
 
bool hasChangedInterfaceData (const Data &D) const
 
bool hasChangedInterfaceData (const Data &D) const
 
bool hasChangedInterfaceData (const Data &D, const Selector &) const
 
bool hasChangedInterfaceData (const Data &D, const Selector *) const
 
bool hasInterface (const type_info &t) const
 
bool iterateInterfaces (const RefPtr< InterfaceIterationParameter > &IIP)
 
void printInterfaces () const
 
void registerInterface (const type_info &t)
 
void removeInterface ()
 
void removeInterfaceBase (const type_info &InterfaceBaseID)
 
- Public Member Functions inherited from MemCore::Ageable
constexpr Ageable (age_t t) noexcept
 
constexpr Ageable (const Ageable &A) noexcept
 
 Ageable (const volatile Ageable &A) noexcept
 
constexpr const AgeablegetAge () const
 
bool isNewerThan (const Ageable &a) const noexcept
 
bool isOlderThan (const Ageable &a) const noexcept
 
bool isYoungerThan (const Ageable &a) const noexcept
 
bool operator!= (const Ageable &a) const noexcept
 
bool operator< (const Ageable &a) const noexcept
 
bool operator<= (const Ageable &a) const noexcept
 
bool operator<= (const volatile Ageable &a) const volatile noexcept
 
bool operator== (const Ageable &a) const noexcept
 
bool operator> (const Ageable &a) const noexcept
 
bool operator> (const volatile Ageable &a) const volatile
 
bool operator>= (const Ageable &a) const noexcept
 
bool operator>= (const volatile Ageable &a) const volatile noexcept
 
constexpr void resetAge () noexcept
 
void setInfinitelyNew () noexcept
 
age_t time_value () const noexcept
 
age_t time_value () const volatile noexcept
 
Ageabletouch () noexcept
 
age_t update (age_t age) noexcept
 
age_t update (const Ageable &Other) noexcept
 
age_t update (const volatile Ageable &Other) volatile noexcept
 
- Public Member Functions inherited from Fiber::SaveableAttributes
void attributesHaveBeenSaved () const
 
bool attributesNeedSaving () const
 
- Public Member Functions inherited from MemCore::Attributes
MemCore::RefPtr< MemCore::ChunkBasegetAttribute (const std::string &name) const
 
const AgeablegetAttributeAge () const
 
std::pair< bool, T > getAttributeValue (const string &AttributeName, size_t ElementNumber=0) const
 
attributes_t & getAttributeValues ()
 
const attributes_t & getAttributeValues () const
 
size_t getNumberOfAttributes () const
 
bool hasAttribute (const std::string &name) const
 
int Iterate (const Functor &L) const
 
int iterate (Iterator &it) const
 
int iterate_attributes (const Functor &L) const
 
size_t NumberOfAttributes () const
 
void setAttribute (const std::string &name, const MemCore::RefPtr< MemCore::ChunkBase > &AttribData)
 
ResizableChunk< T > & setAttributeValue (const std::string &name, const T &AttribData)
 
ResizableChunk< T > & setAttributeValues (const std::string &name, const std::initializer_list< T > &AttribData)
 
const T & setValue (const T &AttribData, const std::string &name)
 
const T & setValue (const T &AttribData, const std::string &name, const std::string &Comment, const std::string &CommentPrefix="Comment")
 
string toString () const
 
const AgeabletouchAttributes () const
 
const AgeableupdateAttributeAge (const Ageable &A) const
 

Static Public Member Functions

static const CAB_tCreativeArrayNullPtr ()
 
static const RefPtr< Field > & NullPtrField ()
 
- Static Public Member Functions inherited from MemCore::Ageable
static const AgeableInfinitelyNew () noexcept
 
static constexpr const AgeableInfinitelyOld () noexcept
 
static age_t now () noexcept
 

Public Attributes

ListRelativeToBinder< WeakPtr< CreativeArrayBase > > UnsavedCreators
 
- Public Attributes inherited from Fiber::Ownable< Field >
std::unordered_set< MemCore::WeakPtr< Container > > Owners
 The (internal) list of owners.
 
- Public Attributes inherited from Fiber::SaveableAttributes
MemCore::Ageable LastSavedAttributes
 

Static Public Attributes

static constexpr bool use_std__flat_map_for_fragments = false
 

Protected Member Functions

const RefPtr< CreativeArrayBase > & setCreatorViaFragmentIndex (FragmentIndex_t FI, const RefPtr< CreativeArrayBase > &CAB)
 
 ~Field ()
 Destructor.
 

Protected Attributes

MemCore::shared_mutex fragment_mutex
 
fragments_t fragments
 

Related Symbols

(Note that these are not member symbols.)

bool validate (FragmentIndex_t FragmentNumber) const
 Check if a given fragment number is valid within this field.
 
RefPtr< CreativeArrayBasesetDiscardableData (const RefPtr< MemBase > &Mb, const RefPtr< MemCore::Cache > &Cache=MemCore::Cache::MemCache(), const RefPtr< FragmentID > &=nullptr)
 A simplied function for data that can be discarded at any time.
 
RefPtr< CreativeArrayBaseoperator<< (const FieldFragment &FF, const RefPtr< MemBase > &Mb)
 Set a data set to a Field fragment:
 
RefPtr< CreativeArrayBaseoperator>> (const FieldFragment &FF, Field::CAB_t &Result)
 Set a data creator to a Field fragment:
 
RefPtr< CreativeArrayBaseoperator<< (const FieldFragmentRef &FF, const RefPtr< MemBase > &Mb)
 Set a data set to a Field fragment:
 
RefPtr< CreativeArrayBaseoperator<< (const FieldFragmentRef &&FF, const Field::CAB_t &theCreator)
 Set a creator:
 
RefPtr< CreativeArrayBaseoperator>> (const FieldFragmentRef &FF, Field::CAB_t &Result)
 Get a creator:
 

Detailed Description

A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID objects.

Each entry describes a fragment of the entire field.

A field is a dataset which is given on various points of a topological space. It consists of a collection of multidimensional arrays (class MultiArray) with same dimensionality. If there is only one such multidimensional array, then the field is called contiguous, otherwise it is fragmented.

Note that the dimensionality of the arrays only corresponds to the dimensions of the topological space if that one is regular. Otherwise, the arrays will just be one-dimensional

The field class provides aging (a counter telling when it has been modified) and deferred data loading via external I/O layers (which can be added at runtime).

In other words, the data of the field are logically available as multidimensional arrays. As a special case, these data may also be portioned in multiple fragments, which are multidimensional arrays themselves. For instance, this may be useful for data from a domain-decomposed parallel computation. The fragments do not necessarily need to cover the entire domain. A sparse cover may be used to describe one level of an adaptive mesh. Mixing fragments of different dimensionality makes no sense.

A section of the fiber bundle is a Field plus coordinates.

Code Examples ** Set a data set to a Field fragment:

F << "Fragmentname" << Mb;
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID obj...
Definition Field.hpp:245

Create a 3D data array of doubles and set it as Field Fragment:

const auto&[Data, CAB] = F.createData<3,double>({3,3,3}, "First Fragment");
double &Element_at_1_2_0 = (*Data)[ {1,2,0} ];
Element_at_1_2_0 = 42.0;

Create a function creating a data set on-demand when needed (and forgotten if we go short in RAM):

F << "On-Demand Fragment" << []() -> RefPtr<MemBase>
{
return new MemArray<3,double>( MIndex{3,3,3} );
};
See also
Field Concept
Examples
ComputeNormals.cpp, TransparentColoredSurface.cpp, XF_LineSetFragmented.cpp, XF_LineSetHierarchical.cpp, and trimesh.cpp.

Constructor & Destructor Documentation

◆ Field() [1/2]

template<class T , Dims_t N>
Fiber::Field::Field ( const MemCore::MemVector< T > &  Data,
const MultiIndex< N > &  Size,
const RefPtr< FragmentIDCollection > &  theFragmentIDCollection = nullptr 
)
inline

Construct an unfragmented field from a MemVector and a MultiIndex.

Implicitly creates a MemArray of the proper dimension.

◆ Field() [2/2]

template<class T , Dims_t N>
Fiber::Field::Field ( const MemCore::RefPtr< MemCore::TypedChunk< T > > &  Data,
const MultiIndex< N > &  Size,
const RefPtr< FragmentIDCollection > &  theFragmentIDCollection = nullptr 
)
inline

Construct an unfragmented field from a Chunk of data and multidimensional index.

Implicitly creates a MemArray.

Member Function Documentation

◆ addFiberType()

bool Fiber::Field::addFiberType ( TypeList_t TypeList) const
inline

Add the type used by this field to the given TypeList.

The type is supposed to be stored with the properties of this field, see the getProperties() function for more information. This function does NOT load or create any data associated with this Field.

Parameters
TypeListThe list of types that shall on return contain the type of this field.
Returns
false if no type information is available, and consequently no type could be added.

References std::set< typename _Key, typename _Compare, typename _Alloc >::insert().

◆ createData() [1/2]

template<Dims_t N, class T >
std::pair< RefPtr< MemArray< N, T > >, RefPtr< CreativeArrayBase > > Fiber::Field::createData ( const MultiIndex< N > &  Size,
const RefPtr< FragmentID > &  fid = nullptr,
Field::CreationFailAlternative  FailMode = Field::CreationFailAlternative::Persistent,
const WeakPtr< MemCore::Cache > &  theCache = MemCore::Cache::MemCache() 
)
inline

Create a mem array and insert it as a fragment to the Field.

const auto&[Data, CAB] = F.createData<3,double>({3,3,3});
double &Element_at_1_2_0 = (*Data)[ {1,2,0} ];

◆ createData() [2/2]

template<Dims_t N, class T >
std::pair< RefPtr< MemArray< N, T > >, RefPtr< CreativeArrayBase > > Fiber::Field::createData ( const MultiIndex< N > &  Size,
const string &  fragmentname,
Field::CreationFailAlternative  FailMode = Field::CreationFailAlternative::Persistent,
const WeakPtr< MemCore::Cache > &  theCache = MemCore::Cache::MemCache() 
)
inline

Create a mem array and insert it as a fragment to the Field under the given fragmentname:

const auto&[Data, CAB] = F.createData<3,double>({3,3,3}, "My First Fragment");
double &Element_at_1_2_0 = (*Data)[ {1,2,0} ];

◆ Dims()

Dims_t Fiber::Field::Dims ( ) const

The dimensionality of the field, taken from the getProperties().

Returns
If no field fragments are defined or the field is constant (no dimensionality), a negative value is returned.

References getProperties().

◆ getChunk()

RefPtr< MemCore::ChunkBase > Fiber::Field::getChunk ( const RefPtr< FragmentID > &  FID = nullptr) const
inline

Return the stored memory chunk associated with this array.

Will only work of the data for this fragment is contiguous.

◆ getCreator()

RefPtr< CreativeArrayBase > Fiber::Field::getCreator ( const RefPtr< FragmentID > &  fid = nullptr) const

Get the creator of an unfragmented field.

Returns
nullptr, if there are only field fragments or no creator is available.

References MemCore::breakpoint().

Referenced by Fiber::FEM::GetFirstFieldSize::apply(), getCompatibleCreatorF(), getData(), and Wizt::ShaderFields::getShaderDefinitions().

◆ getData()

RefPtr< MemBase > Fiber::Field::getData ( const RefPtr< FragmentID > &  FID = nullptr) const

Get the data of a contigous field.

Returns Null if the data could not be created or the field is fragmented. For fragmented fields, use iterate();

References getCreator().

Referenced by Fiber::GridEvaluator::evalFloatIndices().

◆ getDataByNumericalID()

RefPtr< MemBase > Fiber::Field::getDataByNumericalID ( FragmentIndex_t  NumericalID) const

Get some fragment's data via its numerical fragment ID.

In general, this function will return the field's first fragment data and return a valid result regardless of the field being unfragmented or fragmented. In contrast, function getData() will yield a valid result only if the field is unfragmented. However, numerical IDs are just associated with fragments and in some cases a fragment number zero may no exist at all. Thus it is possible that a field with many fragments yields invalid data on getDataByNumericalID(0)

◆ getElementFiberType()

MemCore::WeakPtr< FiberTypeBase > Fiber::Field::getElementFiberType ( ) const

Retrieve the fiber type that is associated with this field.

It is stored with the properties of this field, see the getProperties() function for more information.

References getProperties().

Referenced by Fiber::FiberIO::HDF5::PrecisionTransformation::getFileType(), getMemoryUsage(), and Wizt::ShaderFields::getShaderDefinitions().

◆ getElementType()

const type_info & Fiber::Field::getElementType ( ) const

◆ getFieldStorageType()

const type_info & Fiber::Field::getFieldStorageType ( ) const

Get the type of the field.

Returns
If no data type information is available, e.g. no field data available at all, then typeid (void) is returned.
Note
The type returned here refers to the type information of the entire field, not of the field's elements! Use getElementType() to retrieve this information.

◆ getFirstCreator()

RefPtr< CreativeArrayBase > Fiber::Field::getFirstCreator ( ) const

In case this is field is fragmented, but there is only one fragment, return the ID of this singular fragment.

Will return Null otherwise.

Referenced by getFirstData().

◆ getFirstData()

RefPtr< MemBase > Fiber::Field::getFirstData ( ) const

In case this is field is fragmented, but there is only one fragment, return the ID of this singular fragment.

Will return Null otherwise.

References getFirstCreator().

◆ getFirstFragmentID()

RefPtr< FragmentID > Fiber::Field::getFirstFragmentID ( ) const

Get the first fragment ID.

This function is useful only for special cases when a field is fragmented into a single fragment and this property is required. In all other cases, iteration over all fragments is highly recommended. This is pretty much always the case.

◆ getFragmentIDCollection()

RefPtr< FragmentIDCollection > Fiber::Field::getFragmentIDCollection ( ) const
overridevirtual

◆ getMemoryUsage()

int Fiber::Field::getMemoryUsage ( memsize_t UsedMemory,
memsize_t WantedMemory 
) const

Get the memory occupied by this field (and all of its fragments).

Note that if fragments are shared then they will be counted twice here.

Returns
Indicates whether this field has loaded any memory objects at all, actually how many fragments here have loaded data.

References getElementFiberType().

◆ getProperties()

RefPtr< MemArrayProperties > Fiber::Field::getProperties ( ) const

Return properties associated with this field.

Note that properties are stored with field fragments as an Interface. All fragments are supposed to provide compatible properties, so this function returns the first one found with an arbitrary fragment.

Referenced by Dims(), getElementFiberType(), and getElementType().

◆ getSize()

RefPtr< SizeInterface > Fiber::Field::getSize ( ) const

The size of the field, which is the sum of all fragments.

Returns
A nullptr will be returned if the size cannot be determined, e.g. due to inconsistent rank of fragments, or no fragments existing here at all.

References MemCore::Intercube::addInterface(), and NumberOfFragments().

◆ isType()

bool Fiber::Field::isType ( const TypeList_t TL) const
inline

Check if the type of this field is contained in the given type list.

Parameters
TLA list of types.

References Fiber::containsType().

◆ iterate()

unsigned Fiber::Field::iterate ( const FragmentIterator_t FI,
bool  parallel = false,
bool  copy_map_internally = false 
) const
       Iterate over fragments of a field using std::function .

    Given a field myField, minimal code using a lambda function for iteration looks like this:
myField.iterate( [](const RefPtr<FragmentID>&FragID, const RefPtr<CreativeArrayBase>&CAB)
{
return true;
}
);

References std::async.

◆ iterate_parallel()

unsigned Fiber::Field::iterate_parallel ( const FragmentIterator_t FI,
bool  copy_map_internally = false 
) const
inline

Iterate over all fragments in parallel.

Same as iterate(,true);

◆ setCreator()

const RefPtr< CreativeArrayBase > & Fiber::Field::setCreator ( const RefPtr< CreativeArrayBase > &  FFC,
const RefPtr< FragmentID > &  fid = nullptr 
)

Sets the creator for an unfragmented field.

An eventually existing creator is overwritten.

Note
Setting an unfragmented field creator does not make sense for fragmented fields. So if nFragments() is larger than one, this function does not make anything meaningfull.

Referenced by Fiber::ComputationalField< FieldOperator >::apply(), and Field().

◆ setLambda()

FunctionalCreator & Fiber::Field::setLambda ( const FunctionalCreator::Functor &  F,
const RefPtr< FragmentID > &  fid = nullptr 
)
inline
       Set a lambda function as on-demand creator for a Field, such
       as in:
RefPtr<Field> ResultField;
ResultField->setLambda( []() -> RefPtr<MemBase>
{
return new MemArray<...>(...);
}
);
Class for N-dimensional MultiArrays with MemCore memory management.
Definition MemArray.hpp:34

Special attention must be given to the captures of the lambda function to avoid dangling references, strong pointers and references to MemBase instances.

◆ setPersistentData() [1/3]

template<class T , Dims_t N>
const CAB_t & Fiber::Field::setPersistentData ( Chunk< T > *  Mb,
const MultiIndex< N > &  Dimensions,
const RefPtr< FragmentID > &  FragID = nullptr,
const RefPtr< MemCore::Cache > &  Cache = MemCore::Cache::MemCache() 
)
inline

A convenience function to set a field's data from a Chunk of data.

Calls setPersistentData(), as data will be kept forever in memory and never discared (use with care).

◆ setPersistentData() [2/3]

template<class T , Dims_t N>
const CAB_t & Fiber::Field::setPersistentData ( const MemCore::RefPtr< Chunk< T > > &  Mb,
const MultiIndex< N > &  Dimensions,
const RefPtr< FragmentID > &  FragID = nullptr,
const RefPtr< MemCore::Cache > &  Cache = MemCore::Cache::MemCache() 
)
inline

A convenience function to set a field's data from a Chunk of data.

Calls setPersistentData(), as data will be kept forever in memory and never discared (use with care).

◆ setPersistentData() [3/3]

const Field::CAB_t & Fiber::Field::setPersistentData ( const RefPtr< MemBase > &  Mb,
const RefPtr< FragmentID > &  fid = nullptr,
const RefPtr< MemCore::Cache > &  Cache = MemCore::Cache::MemCache(),
const string &  ProvenanceInfo = {} 
)

Set data for a certain field fragment that is always kept in memory, the cache reference is just use to trace memory utilization.

As such, all data added to the cache this way will contribute to the overall memory counting, even though the data added here cannot be removed from memory.

Todo:
Revise this API

References Fiber::ElementIterator< T >::length, and MemCore::Ageable::touch().

Referenced by Field(), and Field().

◆ setPersistentData1D()

template<class T >
const CAB_t & Fiber::Field::setPersistentData1D ( const MemCore::RefPtr< Chunk< T > > &  data,
const RefPtr< FragmentID > &  FragID = nullptr,
const RefPtr< MemCore::Cache > &  Cache = MemCore::Cache::MemCache() 
)
inline

A convenience function to set a field's data from a Chunk of data, interpreting them as one-dimensional.

Calls setPersistentData(), as data will be kept forever in memory and never discarded (use with care). Use setPersistentData() to specify another dimensionality that shall be imposed on this data set.

In general, avoid using calls to setPersistentData() and derive from a CreatorBase class instead, such that data may be discarded and re-created on demand if memory is short.

◆ Speak()

void Fiber::Field::Speak ( int  indent = 0,
int  maxindent = -1 
) const

Informative debug message.

Parameters
indentHow much to indent during printf() calls.

Friends And Related Symbol Documentation

◆ operator<<() [1/3]

RefPtr< CreativeArrayBase > operator<< ( const FieldFragment FF,
const RefPtr< MemBase > &  Mb 
)
related

Set a data set to a Field fragment:

F << "Fragmentname" << Mb;

Use Field::setPersistentData() if you need more control such as passing a Cache argument.

◆ operator<<() [2/3]

RefPtr< CreativeArrayBase > operator<< ( const FieldFragmentRef &&  FF,
const Field::CAB_t theCreator 
)
related

Set a creator:

F << "Fragmentname" << CAB;

Use Field::setCreator() if you need more control such as passing a Cache argument.

◆ operator<<() [3/3]

Set a data set to a Field fragment:

F << "Fragmentname" << Mb;

Use Field::setPersistentData() if you need more control such as passing a Cache argument.

◆ operator>>() [1/2]

RefPtr< CreativeArrayBase > operator>> ( const FieldFragment FF,
Field::CAB_t Result 
)
related

Set a data creator to a Field fragment:

F << "Fragmentname" << CAB;

Use Field::setCreator() if you need more control such as passing a Cache argument.

◆ operator>>() [2/2]

RefPtr< CreativeArrayBase > operator>> ( const FieldFragmentRef FF,
Field::CAB_t Result 
)
related

Get a creator:

F << "Fragmentname" >> CAB;

◆ setDiscardableData()

RefPtr< CreativeArrayBase > Fiber::Field::setDiscardableData ( const RefPtr< MemBase > &  Mb,
const RefPtr< MemCore::Cache > &  Cache = MemCore::Cache::MemCache(),
const RefPtr< FragmentID > &  fid = nullptr 
)
related

A simplied function for data that can be discarded at any time.

It makes use of the AlzheimerCreator. ()